r - Shiny submitButton behavior at page load time -


the submit button useful, have not found elegant way suppress output on initial page load.

for example shiny tutorial renders output on load.
http://rstudio.github.com/shiny/tutorial/#more-widgets

how make sure no reactive functions called until submit button pressed?

here code inline example linked above.

#ui.r library(shiny)  # define ui dataset viewer application shinyui(pagewithsidebar(    # application title.   headerpanel("more widgets"),    # sidebar controls select dataset , specify number   # of observations view. helptext function used    # include clarifying text. notably, inclusion of    # submitbutton defers rendering of output until user    # explicitly clicks button (rather doing   # when inputs change). useful if computations required   # render output inordinately time-consuming.   sidebarpanel(     selectinput("dataset", "choose dataset:",                  choices = c("rock", "pressure", "cars")),      numericinput("obs", "number of observations view:", 10),      helptext("note: while data view show specified",              "number of observations, summary still based",              "on full dataset."),      submitbutton("update view")   ),    # show summary of dataset , html table requested   # number of observations. note use of h4 function provide   # additional header above each output section.   mainpanel(     h4("summary"),     verbatimtextoutput("summary"),      h4("observations"),     tableoutput("view")   ) ))    #server.r library(shiny) library(datasets)  # define server logic required summarize , view selected dataset shinyserver(function(input, output) {    # return requested dataset   datasetinput <- reactive({     switch(input$dataset,            "rock" = rock,            "pressure" = pressure,            "cars" = cars)   })    # generate summary of dataset   output$summary <- renderprint({     dataset <- datasetinput()     summary(dataset)   })    # show first "n" observations   output$view <- rendertable({     head(datasetinput(), n = input$obs)   }) }) 

one way use actionbutton (from shiny-incubator package) , isolate. here's writeup explains how use 2 together. inherently more flexible approach submitbutton, bit heavy-handed , not flexible enough.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -