melt.data.table提供错误的错误报告

时间:2014-07-03 11:13:31

标签: r data.table reshape2

当用户在melt.data.table中提供不存在的字段时,

id.vars会显示错误的错误消息。它似乎从measure.vars得到了缺少字段的名称:

library(data.table)
library(reshape2)

x=data.table(id=c(1,1,2,2),phase=c('a','b','a','b'), metric=c(1,2,3,4))
melt(x,id.vars=c("id","phase"), measure.vars = c("non-existent-field"))

给出的错误信息是:

Error in melt.data.table(x, id.vars = c("id", "phase"), measure.vars = c("non-existent-    field")) : 
  Column 'id' not found in 'data'

关注R会话信息:

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              
 [3] LC_TIME=ro_RO.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=ro_RO.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=ro_RO.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=ro_RO.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
[1] reshape2_1.4     data.table_1.9.2

loaded via a namespace (and not attached):
[1] plyr_1.8.1    Rcpp_0.11.1   stringr_0.6.2

我会提交一个错误,但我写在这里,以便其他人可以找到这些信息。我失去了一些时间试图弄清楚发生了什么......: - )

0 个答案:

没有答案