R: Brilliant dateRangeInput format

I am using shiny package for R and I have implemented dateRangeInput in my ui.R:

   dateRangeInput("date", "Date range:",
                       start  = "2013-05-15",
                       end    = "2013-10-01",
                       min    = "2013-05-15",
                       max    = "2013-10-01",
                       format = "dd/mm/yy",
                       separator = " - ")

If I display the selected min and max values, I get the following (strange) output:

Minimum Date:

renderText({(input$date[1])})

Output:

 15840

Maximum date value:

renderText({(input$date[2])})

Output:

15979

Why do I get these numbers at the output, and not selected from ui.R itself: 2013-05-15 and 2013-10-01? And how can I convert it to this format? as.Date does not work.

+4
source share
3 answers

Actual value is days since unix, use format(input$date[1]).

+8
source

You can use something like this

observe({
x <- format(input$date[1])

  cat(x,file="/home/indraneel/temp/r1outfile.txt",append=TRUE)

})
+2
source

dateRangeInput

date_start <- input$dateRangeInput_name_one[1]
date_end <- input$dateRangeInput_name_one[2]

BTW: if you 'date' is an integer, you can convert it to 'date' using the following code:

 date_start_date <- as.Date(date_start, origin = "1970-01-01")
 date_end_date <- as.Date(date_end, origin = "1970-01-01")
0
source

Source: https://habr.com/ru/post/1534804/


All Articles