There are many examples of Shiny apps with eventReactive
with multiple inputs that responds when either of the inputs are invalidated. However, I'm trying to create an app with an eventReactive
that runs when the app is only started, and only when both the Val1 textInput
is updated and the actionButton
is pressed. Below is a stripped-down version of my app.
I've tried the curly brackets, the c()
approach, and !is.null(input$Val) & !is.null(input$Run)
in the event portion, but all without success (for the latter - because I assume that an inputText
is returning a non-NULL value is all cases, but I can't figure out what it returns when invalidated...).
Many thanks!
library(shiny)
library(shinydashboard)
server <- function(input, output, session){
dat <- eventReactive(input$Val1, {
data.frame(x = input$Val1, y = 1)
}, ignoreNULL=FALSE)
output$table <- renderTable({
dat()
})}
sidebar <- dashboardSidebar(
textInput(inputId = "Val1", label = "Val1", value = "5"),
textInput(inputId = "Val2", label = "Val2", value = "51"),
actionButton("Run", "Run", class = "btn-success"))
ui <- dashboardPage(header = dashboardHeader(),
sidebar = sidebar,
body = dashboardBody(mainPanel(fluidRow(tableOutput("table")))))
shinyApp(ui, server)