I'm not much of a shiny expert, but from the dashboards I've been building, here is what I would do. I would create a reactiveValues
variable called selectedData
. Then in my observeEvent
, I would pull the csv and update the selectedData
. The reason why I chose to use reactiveValues
in my app is that they can be stateful rather than just always reacting to some input, and I can call them in other areas of the app that requires the same information. As for using observeEvent
, it's simple because you can then wrap your updateSelectizeInput
within the observer.
shinyServer( function(input, output, session) { # init reactiveValues selectedData <- reactiveValues() observeEvent(input$selectData, { if (input$selectData == "Universities") { selectedData$orgdata <- read.csv("universities.csv") } else if (input$selectData == "Hospitals") { selectedData$orgdata <- read.csv("hospitals.csv") } updateSelectizeInput(session, "Organisations", choices = as.character(unique(selectedData$orgdata$name)), server = TRUE) }) ... # rest of your code })