在某些情况下,melt data.table会生成data.frame

时间:2014-07-11 07:50:38

标签: r data.table

好像有些库禁用了data.table melt。我不确定这是一个错误还是我做错了什么。经过反复试验,我发现GGally是“冒犯”的图书馆之一。

library(data.table)
library(reshape2)
library(GGally)

dt = data.table(mtcars, keep.rownames = T)
m = melt(dt, id.var = "rn")
str(m)
> 'data.frame': 352 obs. of  3 variables

评论出库(GGally)给出:

> Classes ‘data.table’ and 'data.frame':    352 obs. of  3 variables

详细说明:

sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] GGally_0.4.5     reshape_0.8.4    plyr_1.8         ggplot2_0.9.3.1  reshape2_1.2.2   data.table_1.9.2

loaded via a namespace (and not attached):
 [1] colorspace_1.2-4   dichromat_2.0-0    digest_0.6.4       grid_3.1.0         gtable_0.1.2       labeling_0.2       MASS_7.3-31       
 [8] munsell_0.4.2      proto_0.3-10       RColorBrewer_1.0-5 scales_0.2.3       stringr_0.6.2      tools_3.1.0     

1 个答案:

答案 0 :(得分:0)

更新GGally解决了这个问题。

"从新闻中,它[GGally]移动ggplot2并重塑为Imports而不是Depends" [Ananda Mahto]