带日期的R闪亮表 [英] R shiny table with dates

查看:69
本文介绍了带日期的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:

但是当我尝试将查询的结果添加为闪亮时,列'not_outlier_date'看起来有所不同:

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

我希望使用与第一张图片相同的日期格式。

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

我该如何解决

推荐答案

尝试使用此格式:

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

问题在于 Shiny 用于显示表的 xtable 库。似乎有与 date列相关的错误,如此 SO问题,然后(关闭)发亮的问题。不过,不确定是否适用于您的 xtable 版本。

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.

这篇关于带日期的R闪亮表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆