Hello guys, I am quite new to developing in Shiny. I came across a rather strange non-specific error in this RegEx:
library(shiny)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("FileInput", label = "Dataset", choices = ls("package:datasets")),
checkboxInput("cmpr", "Compare with old dataset?"),
uiOutput("getOldData"),
actionButton("make", label = "Never does anything")
),
mainPanel(
h3("Showing data"),
tabsetPanel(
tabPanel("New data", tableOutput("first")),
tabPanel("Old data", tableOutput("second"))
)
)
)
)
server <- function(input, output, session) {
datasetInput <- eventReactive(input$FileInput, get(input$FileInput, "package:datasets")) # load dataset
output$getOldData <- renderUI({
req(input$cmpr)
selectInput("FileInputOld", label = "Dataset", choices = ls("package:datasets")) # show options for 2nd dataset if wanted
})
datasetInputOld <- eventReactive(input$FileInputOld, get(input$FileInputOld, "package:datasets")) # load 2nd dataset
observeEvent(datasetInput(), output$first <- renderTable(datasetInput()))
observeEvent(datasetInputOld(), output$second <- renderTable(datasetInputOld()))
observeEvent(input$make, {
if (!(datasetInputOld())) { # gets silent error visible only in debug mode
print("Error 1") # this never happens
} else {
print("Error 2") # this never happens either
}
})
}
shinyApp(ui = ui, server = server)
Perhaps it is due to my lack of knowledge, but I find it interesting since the error is silent and non-specific (when accessing datasetInputOld() in the example above R gives: "Error: " and that's it..
Cheers,
Jan