Hello I have a simple shiny app below. Here is the df:
location = c("100 ail","16th and Whitmore","40AB01 - ANTWERPEN","100 ail","16th and Whitmore","40AB01 - ANTWERPEN")
date = c("2015-09-01 00:00:00","2016-03-06 19:00:00","2016-11-22 15:00:00","2018-02-01 09:30:00", "2018-02-01 03:00:00", "2017-03-07 10:00:00")
pm25=c("FALSE","FALSE","FALSE","FALSE","FALSE","FALSE")
pm10=c("TRUE","FALSE","FALSE","TRUE","FALSE","FALSE")
no2=c("TRUE","FALSE","FALSE")
latitude=c(47.932907,41.322470,36.809700,47.932907,41.322470,36.809700)
longitude=c(106.92139000,-95.93799000
,-107.65170000,106.92139000,-95.93799000
,-107.65170000)
df = data.frame(location, date,latitude,longitude,pm25,pm10,no2)
and the app:
ui = fluidPage(
uiOutput("dt"),
uiOutput("dt2"),
submitButton(text = "Submit", icon = NULL, width = NULL),
shiny::dataTableOutput("merged")
)
#server.r
#df$location <- gsub( " " , "+" , df$location)
server = function(input, output, session) {
output$dt<-renderUI({
dateInput('date',
label = 'First Available Date',
value = df$date
)
})
output$dt2<-renderUI({
dateInput('date2',
label = 'Last available Date',
value = df$date
)
})
output$merged <- shiny::renderDataTable({
df %>%
filter(date >= input$dt & date <= input$dt2)
})
}
shinyApp(ui = ui, server = server)
The df I want to display as datatable should take as inputs tha dates provided by the 2 selectInput() as range and changes its appearance everytime they are updated. Can this be done? Or dateInput() just displays the data that it takes from the beginning and cannot be used for subsetting?