Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: Shiny dateRangeInput format

Tags:

date

r

shiny

I am using the packet shiny for R and I implemented a 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 (weird) output:

Min date value:

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

Output:

 15840

Max date value:

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

Output:

15979

Why do I get these numbers in the output and not the selected ate from the ui.R itself: 2013-05-15 and 2013-10-01 ? And how can I transform it to such a format? as.Date does not work.

like image 498
maRtin Avatar asked Apr 03 '14 10:04

maRtin


2 Answers

The actual value is days since the unix epoch, use format(input$date[1]).

like image 68
mdsumner Avatar answered Sep 28 '22 03:09

mdsumner


You can use some thing like this

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

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

})
like image 44
Indraneel Avatar answered Sep 28 '22 03:09

Indraneel