0

I'm writing a Shiny App to collect inputs and run a process with these inputs before providing various output such a table and chart.

I need to control the execution of the process function until the an action button is pressed. I've set up the initial code and wrapped the function with reactive() but I'm unsure how to link this to the action button.

UI.R

library(shiny)
shinyUI(navbarPage(
  title = 'Demo',


  tabPanel('Inputs',textInput("city", "Enter a city"),
           textInput("country", "Enter a country"),
           actionButton("process", "Process")


  ),
  tabPanel('Processing', textOutput('tab2'))

))

server.R

library(shiny)
shinyServer(function(input, output) {

  proc <-reactive({processFunction(input$country, input$city)})

  output$tab2 <- renderTable({proc()$table1})

})

Any ideas how to control the execution?

1

1 Answer 1

1

I sorted it using isolate() and adding a dependency to the action button.

 output$tab2 <- renderText({
    if (input$process == 0)
      return()

    isolate({ function call })
  })

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.