melt.data.table may crash when measure.vars contains variables not in data.table

孤街浪徒 提交于 2019-12-11 02:46:54

问题


The following code crashes in my installation:

library(data.table)
library(reshape2)
x = data.table(a=c(1,2),b=c(2,3),c=c(3,4))
melt(x,id.vars="a") # OK
melt(x,id.vars="a",measure.vars=c("c","d")) # Crashes

The message is the following:

*** caught segfault ***
address 0x21000038, cause 'memory not mapped'
Traceback:
1: melt.data.table(x, id.vars = "a", measure.vars = c("c", "d"))
2: melt(x, id.vars = "a", measure.vars = c("c", "d"))

Here is the 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              
 [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     
> library(data.table)
data.table 1.9.2  For help type: help("data.table")
> library(reshape2)
> 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              
 [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

It may be the same problem reported here: melting data.table seems to crash RStudio?


回答1:


Thanks for the post and the bug report. This is now fixed with commit 1261 of v1.9.3. From NEWS:

  • melt now returns friendly error when meaure.vars are not in data instead of segfault. Closes #699. Thanks to vsalmendra for this post on SO and the subsequent bug report.

Please write back if the issue persists.



来源:https://stackoverflow.com/questions/24326797/melt-data-table-may-crash-when-measure-vars-contains-variables-not-in-data-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!