我想在闪亮,但反应状态的动态SQL查询使用selectInput使用[R闪亮selectInput似乎出差错:不允许在动态查询
操作,而不积极反应的情况下。
我实际使用RODBC与SQL查询,但是这是一个重复的例子,试图(你试图做一些事情,只能从被动式或观察者内完成)。
服务器:
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"))
感谢nilsole,那selectedCityData引用是紧紧的;-) – dataphile