I'm making an app to analyse time series data with Shiny. The data I work with looks like:
V1 V2
1 2013-02-04 18:15:00 -4.746
2 2013-02-04 18:20:00 -4.745
3 2013-02-04 18:25:00 -4.746
4 2013-02-04 18:30:00 -4.747
5 2013-02-04 18:35:00 -4.747
6 2013-02-04 18:40:00 -4.747
I want to plot the data in a table:
output$view <- renderTable({
head(datasubset(),
n=nrow(datasubset()))
})
Doing so I get an error when running Shiny:
Error in Math.POSIXt(x + ifelse(x == 0, 1, 0)) :
'abs' not defined for "POSIXt" objects
Does anyone have a solution for this error?
UPDATE: The error is caused by xtable: renderTable uses xtable() to generate the output, and it looks like xtable doesn't play well with dates in general.
An issue has been filed here by Winston Chang: https://github.com/rstudio/shiny/issues/129
A workaround is available at: R: xtable and dates
Look into the strftime function in base package. Strftime formats POSIXt objects as character, and lets you specify the format.
You could do someting like this before you print the table:datasubset$V1 <- strftime(datasubset$V1, format="%Y-%m-%d %H:%M:%S")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With