我在这里找到了如何使用reachable
函数制作表格的示例,但是没有找到(也在不同的来源中)如何做双列名称
library(reachable)
library(data.table)
data<-structure(list(date = structure(c(1580428800, 1582848000, 1585612800,
1588204800, 1580428800, 1582848000, 1585612800, 1588204800, 1580428800,
1582848000, 1585612800, 1588204800, 1580428800, 1582848000, 1585612800,
1588204800, 1580428800, 1582848000, 1585612800, 1588204800, 1580428800,
1582848000, 1585612800, 1588204800, 1580428800, 1582848000, 1585612800,
1588204800, 1580428800, 1582848000, 1585612800, 1588204800, 1588204800
), class = c("POSIXct", "POSIXt"), tzone = "UTC"), group = c("a",
"a", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b",
"b", "b", "c", "c", "c", "c", "c", "c", "c", "c", "d", "d", "d",
"d", "d", "d", "d", "d", "e"), value = c(54.3923333333333, 52.278,
43.5828333333333, 41.39875, 54.9545, 53.12025, 46.044, 44.4135,
-14.8910166666667, -12.3993916666667, -9.64581666666667, -9.449925,
-13.4157916666667, -11.1878416666667, -9.567625, -9.47255833333334,
92, 66, 42, 63.75, 81, 55, 31, 59.375, 916.175525, 739.877458333333,
533.883366666667, 658.222004166667, 955.311075, 752.5635875,
531.2294, 722.806975, 722.806975), multiplication_factor = c(1,
2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 33, 34, 35, 36, 37,
38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51)), row.names = c(NA,
-33L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x0000012c2e1a1ef0>)
data<-dcast(setDT(data), group ~ date, value.var=c("value", "multiplication_factor"))
reactable(data)
但是,使用此代码reachable() 创建了一个表,date
并且value
/multiplication_factor
被连接在一起以显示列名。我想让列名的第一行/层显示date
,第二行显示变量(value
/ multiplication_factor
)
是否可以使用相同的功能做与此表类似的事情?