Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R shiny table with dates

Tags:

date

r

shiny

I'm making an app to analyse some data with Shiny.

When I directly send query to database, I can see good rezults:

enter image description here

But when I try to put results from this query to shiny, column 'not_outlier_date' look different:

enter image description here

I want to have the same date format, as in the first picture.

I was trying, on table, that I get from database, add:

  not_outlier_dates[,2]<-as.Date(as.numeric(as.vector(unlist(not_outlier_dates[,2]))))

But it doesn't make any changes and works with warning:

 Warning in formatC(x = c(16065, 16137, 16064, 15707, 16063, 15775, 15782 :
 class of 'x' was discarded

How can I solve this date format problem?

like image 801
Marta Avatar asked Mar 14 '14 12:03

Marta


1 Answers

Try using this:

not_outlier_dates[,2] <- as.character(not_outlier_dates[,2])

The problem lies in the xtable library that Shiny uses to display tables. It seems there are bugs related to date columns, as stated in this SO question and this (closed) Shiny issue. Not sure if that still applies or if it applies to your xtable version, though.

like image 187
Guillem Vicens Avatar answered Oct 14 '22 05:10

Guillem Vicens