I'm trying to use a selectInput in a dynamic sql query with Shiny but the reactive state seems to go awry :
Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
I am actually using RODBC with a sql query but this is an attempt at a reproducible example.
Server :
data(citytemp, package = "highcharter")
function(input, output) {
getCityData <- function(selectedCity) {
return(citytemp[[selectedCity]])
# hardcoded :
# return(citytemp$tokyo)
# dynamic sql query
# sql <- paste0("select * from cities where name = ", selectedCity)
}
cityData <- getCityData(input$cityFilter)
#render highchart with cityData
}
UI :
library("shiny")
library("shinydashboard")
selectInput("cityFilter", label = "City", choices = list("Tokyo" = "tokyo", "London" = "london", "Berlin" = "berlin"))
box(width = 6, highchartOutput("highchart"))