使用日期时间列创建 data.table 时出现问题:
> mdt <- data.table(id=1:3, d=strptime(c("06:02:36", "06:02:48", "07:03:12"), "%H:%M:%S"))
> class(mdt)
[1] "data.table" "data.frame"
> print(mdt)
Error in `rownames<-`(`*tmp*`, value = paste(format(rn, right = TRUE), :
length of 'dimnames' [1] not equal to array extent
Enter a frame number, or 0 to exit
1: print(list(id = 1:3, d = list(sec = c(36, 48, 12), min = c(2, 2, 3), hour = c(6, 6, 7), mday = c(31,
2: print.data.table(list(id = 1:3, d = list(sec = c(36, 48, 12), min = c(2, 2, 3), hour = c(6, 6, 7), m
3: `rownames<-`(`*tmp*`, value = paste(format(rn, right = TRUE), ":", sep = ""))
创建为 data.frame 并转换为 data.table 有效!
> mdf <- data.frame(id=1:3, d=strptime(c("06:02:36", "06:02:48", "07:03:12"), "%H:%M:%S"))
> print(mdf)
id d
1 1 2014-01-31 06:02:36
2 2 2014-01-31 06:02:48
3 3 2014-01-31 07:03:12
> mdt <- as.data.table(mdf)
> print(mdt)
id d
1: 1 2014-01-31 06:02:36
2: 2 2014-01-31 06:02:48
3: 3 2014-01-31 07:03:12
> class(mdt)
[1] "data.table" "data.frame"
我错过了什么或者是错误吗?如果出现错误,我应该在哪里报告?
注意我使用 R 版本 3.0.0,并且看到一些警告。使用版本 3.0.2 构建的软件包。这会是问题吗?我应该升级 R 本身吗?我所做的其他一切似乎都有效。