【发布时间】:2021-03-26 12:29:43
【问题描述】:
我有带列的数据
Time - AgentID -- SimulationID -- discountFactor -- displacement
对于每个by =.(AgentID,SimulationID,discountFactor),我要计算acf(displacement, doPlot=False)$acf,并将其输出到新的data.table dStat。但是由于acf(...)$acf的输出大小小于Time,所以不能直接定义新列,所以需要新建data.table。
我该怎么做?
我的整个数据集的一部分:
structure(list(Time = c(2.00099550677104, 2.00108827485947, 2.00108827485947,
2.00108827485947, 2.00108827485947, 2.00108827485947, 2.00108827485947,
2.00108827485947, 2.00108827485947, 2.00108827485947, 2.00108827485947
), AgentID = c(40L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L),
SimulationID = c(2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L), discountFactor = c(0.2, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8,
0.8, 0.8, 0.8, 0.8), displacement = c(-4L, -7L, -1L, 6L,
-6L, 6L, -1L, -4L, 0L, 0L, -3L)), row.names = c(NA, -11L), class = c("data.table",
"data.frame"), .internal.selfref = <pointer: 0x55a2cca3bde0>, sorted = "Time")
【问题讨论】:
标签: r data.table