Reputation: 779
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?
Upvotes: 0
Views: 655
Reputation: 779
I sorted it using isolate() and adding a dependency to the action button.
output$tab2 <- renderText({
if (input$process == 0)
return()
isolate({ function call })
})
Upvotes: 1