如何从闪亮的数据表中删除时区?
How to remove timezone from datatable in Shiny?
目前,当我将 PerformanceAnalytics
包的一些输出包装到 Shiny 的 datatable
(DT 包)中时,日期得到 T:00:00:00Z 在浏览器中附加到它们。
例如,2015-01-31T00:00:00Z 并且只需要 2015-01-31.
如何防止这种情况发生并只显示 yyyy-mm-dd?数据表中是否有我不知道的设置?
测试代码
# sample data from dput
rets <- structure(c(NA, 0.00262056199999994, 0.000126308999435887, -0.00261834288319462,
0.0367651429321201, -0.00809892429976078, 0.0139021665335084,
-0.0134753927842055, -0.0140747519238918, -0.0163687182009664,
-0.00980900143012819, 0.00832756801047285),
class = c("xts","zoo"),
.indexCLASS = c("POSIXct", "POSIXt"),
tclass = c("POSIXct", "POSIXt"),
.indexTZ = "UTC", tzone = "UTC",
index = structure(c(1414800000,
1417305600, 1419984000, 1422662400,
1425081600, 1427760000, 1430352000,
1433030400, 1435622400, 1438300800,
1440979200, 1443571200),
tzone = "UTC",
tclass = c("POSIXct", "POSIXt")),
.Dim = c(12L, 1L),
.Dimnames = list(NULL, "nav"))
library(PerformanceAnalytics)
library(DT)
library(xts)
DT::datatable(table.Drawdowns(rets))
TABLE 看起来像什么
您可以使用格式化功能,例如:
DT::datatable(table.Drawdowns(rets)) %>% formatDate(c(1,2,3), method = 'toDateString')
给出:
目前,当我将 PerformanceAnalytics
包的一些输出包装到 Shiny 的 datatable
(DT 包)中时,日期得到 T:00:00:00Z 在浏览器中附加到它们。
例如,2015-01-31T00:00:00Z 并且只需要 2015-01-31.
如何防止这种情况发生并只显示 yyyy-mm-dd?数据表中是否有我不知道的设置?
测试代码
# sample data from dput
rets <- structure(c(NA, 0.00262056199999994, 0.000126308999435887, -0.00261834288319462,
0.0367651429321201, -0.00809892429976078, 0.0139021665335084,
-0.0134753927842055, -0.0140747519238918, -0.0163687182009664,
-0.00980900143012819, 0.00832756801047285),
class = c("xts","zoo"),
.indexCLASS = c("POSIXct", "POSIXt"),
tclass = c("POSIXct", "POSIXt"),
.indexTZ = "UTC", tzone = "UTC",
index = structure(c(1414800000,
1417305600, 1419984000, 1422662400,
1425081600, 1427760000, 1430352000,
1433030400, 1435622400, 1438300800,
1440979200, 1443571200),
tzone = "UTC",
tclass = c("POSIXct", "POSIXt")),
.Dim = c(12L, 1L),
.Dimnames = list(NULL, "nav"))
library(PerformanceAnalytics)
library(DT)
library(xts)
DT::datatable(table.Drawdowns(rets))
TABLE 看起来像什么
您可以使用格式化功能,例如:
DT::datatable(table.Drawdowns(rets)) %>% formatDate(c(1,2,3), method = 'toDateString')
给出: