我正在开发一个闪亮的应用程序,它从ui.R获取两个日期输入,并且(希望)将这些输入作为字符串传递给SQL查询。我一直在努力:
Error in cat(list(...), file, sep, fill, labels, append) :
argument 1 (type 'closure') cannot be handled by 'cat'
这是ui.R:
library(shiny)
shinyUI(fluidPage(
titlePanel(""),
#create side tab list
sidebarLayout(
sidebarPanel(
selectInput("dataset", "Data:",
choices = c("Alerts", "Jams")),
checkboxGroupInput(
inputId = "dataView",
label = "Add Data to Map",
choices = c(
"Polygon" = "poly",
"Points" = "data"
)),
dateInput("dateStart", "Start Date: ", min = "2014-12-12", max = Sys.Date()),
dateInput("dateEnd", "End Date: ", min = "2014-12-12", max = Sys.Date()),
submitButton("Submit")
),
mainPanel(
tabsetPanel(type = 'tabs',
tabPanel("Map", plotOutput("map")),
tabPanel("Plots", plotOutput("plot")),
tabPanel("Table", dataTableOutput(outputId = "table"))
),
verbatimTextOutput("alert_query")
)
)
))
以下是删除了敏感信息的服务器.R的违规行为:
library(shiny)
library(dplyr)
library(RODBC)
shinyServer(function(input, output) {
#query db
dateEnd_query <- renderText({
reactive({
input$dateEnd
})
})
dateStart_query <- renderText({
reactive({
input$dateStart
})
})
wz <- odbcConnect("SQL", uid = "usr", pwd = "pwd" )
output$alert_query <- renderText({
reactive({
paste("SELECT [vars] ",
"FROM ",
paste0("WHERE [startTime] >= ", "'", dateStart_query(),"'"),
paste0("AND [startTime] <= ", "'", dateEnd_query() , "'"),
"AND [city] = '' ")
})
})
})