data.table dcast()是否删除'data.table'属性?

时间:2016-10-06 13:14:39

标签: r data.table

似乎dcast()返回data.frame,尽管输入参数是data.table:

d  <- data.table(id = c(1,2,3), group = c('a','a','b'), x = c(10,20,30))
dc <- dcast(d, id ~ group, value.var = 'x')

> class(d)
[1] "data.table" "data.frame"
> class(dc)
[1] "data.frame"

有没有办法让dcast()返回data.table?

> sessionInfo('data.table')
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

attached base packages:
character(0)

other attached packages:
[1] data.table_1.9.6 

0 个答案:

没有答案