ActionButton or SubmitButton

1,013 views
Skip to first unread message

Sam

unread,
Feb 12, 2013, 5:04:38 AM2/12/13
to shiny-...@googlegroups.com
Hi all, 
I would like to build an app which takes parameters from the UI and, when the user click on a button, the server executes a homemade function. Finally, i have to plot the results.
I do not need the reactive function since I want to use the server side as a computation machine.

I tried to do such app based on the tutorial of Shiny but the problem is that the computation in my function begins immediately, even before I clicked on the submitButton.
 I do not know how to wait that the button is clicked to execute myFunction.

######UI.R code : 
library(shiny)
library(shinyIncubator)

# Define UI for miles per gallon application
shinyUI(pageWithSidebar(
  
  # Application title
  headerPanel("perTurbo Classification"),
  
  # Sidebar with controls to select the variable to plot against mpg
  # and to specify whether outliers should be included
  sidebarPanel(
    selectInput("dataset", "Choose a dataset:", 
                choices = c("at_chloro", "tan2009r1", "dunkley2006")),

    submitButton("Execute"),

      
  ),
  
  # Show the caption and plot of the requested variable against mpg
  # Show a tabset that includes a plot, summary, and table view
  # of the generated distribution
  mainPanel(
    tabsetPanel(
      tabPanel("Plot", plotOutput("plot"))
)
  )
))


###### server.R code

# Define server logic required to plot various variables against mpg
shinyServer(function(input, output) {
  
   #
  paramInput <- function() {
    list("dataset" = input$dataset )
    
  }
   
  output$plot <- reactivePlot(function() {
    theDataSet <- datasetInput()
    foo <- myFunction(theDataset)
   plot(foo)
  })
  
 
  
})




Thanks for your help

Sam

Vincent

unread,
Feb 12, 2013, 2:13:47 PM2/12/13
to shiny-...@googlegroups.com
You may want to use actionButton and isolate. See this thread:

Sam

unread,
Feb 13, 2013, 7:32:58 AM2/13/13
to shiny-...@googlegroups.com
Thanks, that works ! :)

Sam
Reply all
Reply to author
Forward
0 new messages