问题就不同了。Shiny无法读取日期和时间之间的间隔,因此我将其替换为“+”。
output$loc<-renderUI({
selectInput("loc", label = h4("Choose location"),
choices = locations$location ,selected = 1
)
})
rt<-reactive({
locations$location <- gsub( " " , "+" , locations$location)
AQ<- aq_measurements(location = input$loc,date_from = as.Date(as.POSIXct(subset(locations$firstUpdated,(locations[,1]==input$loc))
,format="%Y-%m-%d %H:%M:%S"))
, date_to = as.Date(as.POSIXct(subset(locations$lastUpdated,(locations[,1]==input$loc)),format="%Y-%m-%d %H:%M:%S"))
)
met <- importNOAA(year = 2014:2018)
colnames(AQ)[9] <- "date"
merged<-merge(AQ, met, by="date")
# date output -- reports user-selected state & stop dates in UI
merged$location <- gsub( " " , "+" , merged$location)
merged$date <- gsub( " " , "+" , merged$date)
merged
})
output$dt<-renderUI({
selectInput("dt", label = h4("Choose Dates"),
choices = as.character(rt()[,1]),
selected = 1
)
})
#DT
output$merged <- shiny::renderDataTable({
subset(rt(),(rt()[,1]==input$dt))
})