Rshiny:如何在SQL查询中正确使用dateRangeInput
我很难正确地编写一个查询,该查询将使用我在ui中为我正在设计的应用程序选择的输入值。我似乎不知道如何在查询中指定如何选择dateRangeInput中指定的日期值Rshiny:如何在SQL查询中正确使用dateRangeInput,r,shiny,R,Shiny,我很难正确地编写一个查询,该查询将使用我在ui中为我正在设计的应用程序选择的输入值。我似乎不知道如何在查询中指定如何选择dateRangeInput中指定的日期值 # Step 2 这是我的ui的代码: ui <- fluidPage(theme = shinytheme("cerulean"), titlePanel("Title of Project"), navbarPage(
# Step 2
这是我的ui的代码:
ui <- fluidPage(theme = shinytheme("cerulean"),
titlePanel("Title of Project"),
navbarPage(
"Number of Samples App",
checkboxGroupInput(inputId = "Assay",
label = "Assay Type:",
choices = c("MVP1","EF","Methylation","WGS","WES","Metabolomics","All" )), #Assay
checkboxGroupInput(inputId = "Vendor",
label = "Vendor:",
choices = c("AKE","BSA")), #Vendor
dateRangeInput(inputId = "Date", label = "Sample Date Range:"), #Date
mainPanel(
h1("Output:"),
dataTableOutput("table")) #table
) #closing navbarPage
) #closing fluidPage UI
ui
# Step 3: Tell server what input variables are from ui, and
# send output variables back to ui
#Tell server how to assemble inputs and outputs
server <- function(input, output){
#Storing values in myData variable
myData <- reactive({
paste(input$Assay, input$Vendor, input$Date)
#Opening database connection
connectiontodb <- dbConnect(RSQLite::SQLite(), "example.sqlite")
#Sample query of example.sqlite dataset using date input
exampledataSQLQuery <- dbGetQuery(connectiontodb, "SELECT count(*) FROM exampletable WHERE collection_dt between ",as.character(input$Date[1])," and ",as.character(input$Date[2]),"")
#Closing connection to database
dbDisconnect(connectiontodb)
#Returning results of query
exampledataSQLQuery
})
output$table <- renderDataTable({
myData()
})
}