I have this simple Shiny app in which I want the user to choose among four dataframes -- namely df1, df2, df3 and df4 -- the one than will be displayed using DT:dataTableOutput. The problem is I get this error:
Error in dots_list(...) : object 'df_opt' not found
And I do not know why. I thought the error messages was firing because of something related to the input$df_opt argument I previously had in eventReactive, but then I removed it by adding a button input. Nevertheless, I keep getting the same error message
Does anyone understand why I'm getting this message?
This is a reproducible example of my app:
library(shiny)
library(DT)
choices_df <- c("opt1", "opt2", "opt3", "opt4")
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
radioButtons(
inputId = df_opt,
label = "Choose a database",
choices = df_choices,
selected = choices_df[1] ),
actionButton(
inputId = df_button,
label = "")
),
mainPanel(
DT::dataTableOutput("base_p1")
)
))
server <- function(input, output) {
df_selected <- eventReactive(
input$df_button, {
if( input$df_opt == choices_df[1] ){
df1
}
if( input$df_opt == choices_df[2] ){
df2
}
if( input$df_opt == choices_df[3] ){
df3
}
if( input$df_opt == choices_df[4] ){
df4
}
})
output$base_p1 <- DT::renderDataTable( df_selected(), filter = "top")
}
shinyApp(ui = ui, server = server)
df_optin quotes"df_opt"ininputId?