我只是从R开始。
我的数据在一个 csv 文件中。这是一个摘录:
p, t, a, b, c
p01, t1, 4292.226015, 4292.226015, 0.0
p01, t3, 693.795607, 693.795607, 0.0
p02, t1, 262.798468, 262.798468, 0.0
p02, t2, 113.381499, 113.381499, 0.0
p02, t3, 325.854107, 325.854107, 0.0
p02, t4, 428.073246, 428.073246, 0.0
p02, t5, 319.010848, 319.010848, 0.0
...我正在像这样加载它:
data <- read.csv(file='data.csv',head=TRUE,sep=',')
最后三列是持续时间值(以秒为单位),我希望它们成为 lubridate 的duration
对象。我怎样才能做到这一点?
我尝试在加载 csv 后转换列,如下所示:
data$a <- dseconds(data$a)
data$b <- dseconds(data$b)
data$c <- dseconds(data$c)
......起初它似乎工作。除了,当我要求总结时,有几个警告我在解释时遇到了一些麻烦:
> summary(tasks)
group task a b c
p01:2 t1:2 Min. : 113.4 Min. : 113.4 Min. :0
p01:5 t2:1 1st Qu.: 290.9 1st Qu.: 290.9 1st Qu.:0
t3:2 Median : 325.9 Median : 325.9 Median :0
t4:1 Mean : 919.3 Mean : 919.3 Mean :0
t5:1 3rd Qu.: 560.9 3rd Qu.: 560.9 3rd Qu.:0
Max. :4292.2 Max. :4292.2 Max. :0
Warning messages:
1: In quantile.default(object) :
Class 'Duration' has no 'names' slot; assigning a names attribute will create an invalid object
2: In summary.default(X[[3L]], ...) :
Class 'Duration' has no 'names' slot; assigning a names attribute will create an invalid object
3: In summary.default(X[[3L]], ...) :
Setting class(x) to multiple strings ("summaryDefault", "table", ...); result will no longer be an S4 object
>