![](/img/trans.png)
[英]SQLite and Shiny/flexdashboard: Cannot embed a reactiveValues() object in a SQL query
[英]Shiny flexdashboard that displays the results of a query
我正在尝试创建一个闪亮的flexdashboard,以显示SQL查询的结果。 我的代码包括输入查询的网站,月份和年份的可选参数。 我一辈子都无法弄清楚如何呈现查询结果,将不胜感激。 这是代码:
# ---
# title: "Site Dashboard"
# output: flexdashboard::flex_dashboard
# runtime: shiny
# ---
{r setup, include=FALSE}
library(dplyr)
library(sqldf)
Column {.sidebar}
selectInput("site", label = "WIM Site",
choices = c("26","27"),
selected = "26")
numericInput("month", label = "Month",
value = 12, min = 1, max = 12, step = 1)
selectInput("year", label = "Year",
choices = c("2014","2015","2016"),
selected = "2015")
Column
-----------------------------------------------------------------------
### Query Results
db <- dbConnect(SQLite(), dbname="N:/TrafMon/WIM/Ian/minWIM.sqlite")
query<-reactive({
paste("SELECT * FROM", paste("wim",input$site,"_", input$year,
sep=""),paste("WHERE month =="),input$month, "LIMIT 5")
})
a <- reactive({
sqldf(query, dbname="N:/TrafMon/WIM/Ian/minWIM.sqlite")
})
query
renderTable(a)
我试过使用renderTable(a())
, renderText(a())
, renderText(a)
渲染表。 似乎没有任何作用。 我应该注意,在Rstudio中运行相同的查询代码会产生预期的输出,因此问题不在于查询。
要使用reactive
您需要在所有反应式中的()
之后()
添加()
)
喜欢:
sqldf(query(), dbname="N:/TrafMon/WIM/Ian/minWIM.sqlite")
renderTable(a())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.