I have a shiny app in which I can load a file. I wan't to extract the min and max date range from my file use these as input for a slider input.
Here is what I have so far
ui <- fluidPage(
dateRangeInput(inputId = "date", label = "Input a date range", start=textOutput("datemin") , end = textOutput("datemax"),"%d-%m-%y"))
)
server = function(input, output){
output$datemin <- renderText({as.character(as.Date(paste("01",as.character.Date(min(dataset()$date)),sep="-"),"%d-%y-%m"))})
output$datemax <- renderText({as.character(as.Date(paste("01",as.character.Date(max(dataset()$date)),sep="-"),"%d-%y-%m"))})
}
I know the outputs datemin and datemax are a bit tricky, this is because the "date" column in the dataset is a string such as "13-05" for may 2013 (the dataset is a summarized version with monthly means for some values)
Edit.
I've tried 3 different outputs for my date in order to check the format, and I display them as textoutput as follows :
UI
textOutput("datemin1"),
textOutput("datemin2"),
textOutput("datemin3"),
Server
output$datemin1 <- renderText({(as.character.Date(min(dataset()$date)))})
output$datemin2 <- renderText({as.character(as.Date(paste("01",as.character.Date(min(dataset()$datem)),sep="-"),"%d-%y-%m"))})
output$datemin3 <- reactive({as.Date(as.yearmon(min(dataset()$datem)))})
The outputs are the following :
datemin1 : 14-01
datemin2 : 2014-01-01
datemin3 : 0014-01-01
But still when I try to use an output as an input value for my slider as follows :
sliderInput("slider1", "Date Range",
min = textOutput("datemin2"), max=textOutput("datemax2"),
value = textOutput("datemax2")
),
I get this error : ERROR: non-numeric argument to binary operator
Thanks
sliderInput
? What is the complete date format in your dataset? – Sagar