使用Shiny renderTable显示POSIXt对象

Tim*_*ror 6 r shiny

我正在制作一个用Shiny分析时间序列数据的应用程序.我使用的数据如下:

                   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
Run Code Online (Sandbox Code Playgroud)

我想在表格中绘制数据:

output$view <- renderTable({
  head(datasubset(), 
  n=nrow(datasubset()))
})
Run Code Online (Sandbox Code Playgroud)

这样做我在运行Shiny时出错:

Error in Math.POSIXt(x + ifelse(x == 0, 1, 0)) : 
      'abs' not defined for "POSIXt" objects
Run Code Online (Sandbox Code Playgroud)

有没有人有这个错误的解决方案?

更新:该错误是由xtable造成的:renderTable使用xtable()生成的输出,它看起来像xtable不与一般的日期打出好成绩.

Winston Chang在此提出了一个问题:https: //github.com/rstudio/shiny/issues/129

解决方法可在以下位置获得:R:xtable和日期

sna*_*aut 3

查看基础包中的 strftime 函数。Strftime 将 POSIXt 对象格式化为字符,并允许您指定格式。

在打印表格之前,您可以执行以下操作:
datasubset$V1 <- strftime(datasubset$V1, format="%Y-%m-%d %H:%M:%S")