Reputation: 101
I have a Shiny Dashboard with a reactive action button but the button does not update the dashboard.
I have the tabItems split out into their own files and references using source by ui.R.
The tabItem within contain just the following code.
actionButton("go", "Go"),
numericInput("n", "n", 50),
plotOutput("plot")
The server.R file is also split out and references each file using source. The the relavent file contains
randomVals <- eventReactive(input$go, {
runif(input$n)
})
output$plot <- renderPlot({
hist(randomVals())
})
Clicking the actionbutton does not do anything within ShinyDahsboard, but if I run this code as a shiny app on it's own it works fine.
Upvotes: 2
Views: 3676
Reputation: 29387
You should isolate
your button, like so:
Edit: as per @tospig
rm(list = ls())
library(shiny)
shinyApp(
ui=shinyUI(basicPage(
actionButton("go", "Go"),
numericInput("n", "n", 50),
plotOutput("plot")
)),
server=shinyServer(function(input, output, session){
randomVals <- eventReactive(input$go, {
runif(input$n)
})
output$plot <- renderPlot({
hist(randomVals())
})
})
)
Upvotes: 3