<div><div>Hello, </div><div>When attempting to run the line of code below, R crashes. </div><div>I tried it on two systems with same results. </div><div><br></div><div>Any thoughts as to why the crash (as opposed to say an error)? </div>
<div>Thanks for any help and insight</div><div><br></div><div>-- </div><div>Ricardo Saporta</div><div>Graduate Student, Data Analytics</div><div>Professional Science Masters </div><div>Rutgers University, New Jersey</div>
<div>e: <a href="mailto:saporta@rutgers.edu">saporta@rutgers.edu</a></div><div><br></div><div><br></div><div><br></div><div>#---- SAMPLE DATA -------#</div><div>library(data.table)</div><div>test.dt <- structure(list(</div>
<div> ID = c(4089L, 4090L, 4090L, 4091L, 4091L, 4092L, 4092L, </div><div> 4093L, 4093L, 4093L, 4094L, 4094L, 4094L), </div><div> name = c("A", "B", "C", "D", "E", "F", "G", "H", </div>
<div> "I", "J", "K", "L", "M"), </div><div> order = list("A", c("B", "C"), c("B", "C"), c("D", "E"), </div>
<div> c("D", "E"), c("F", "G"), c("F", "G"), </div><div> c("H", "I", "J"), c("H", "I", "J"), </div>
<div> c("H", "I", "J"),c("K", "L", "M"), </div><div> c("K", "L", "M"), c("K", "L", "M"))), </div>
<div> .Names = c("ID", "name", "order"), row.names = c(NA, -13L), </div><div> class = c("data.table", "data.frame"))</div><div><br></div><div><br></div><div>#---- OFFENDING LINE -------#</div>
<div><br></div><div> # this line causes R to crash. </div><div> test.dt[, tc := which(name==order), by=list(ID, name)]</div><div><br></div><div> # this is the line that I should have used</div><div> test.dt[, tc := which(name == order[[1]]), by=list(ID, name)]</div>
<div><br></div><div><br></div><div>#---- SESSION INFO -------#</div><div><br></div><div>## SYSTEM 1: </div><div> > sessionInfo()</div><div>R version 2.15.2 (2012-10-26)</div><div>Platform: x86_64-pc-linux-gnu (64-bit)</div>
<div><br></div><div>locale:</div><div> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=C LC_COLLATE=C LC_MONETARY=C </div><div> [6] LC_MESSAGES=C LC_PAPER=C LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C </div>
<div>[11] LC_MEASUREMENT=C LC_IDENTIFICATION=C </div><div><br></div><div>attached base packages:</div><div>[1] stats graphics grDevices utils datasets methods base </div><div><br></div><div>other attached packages:</div>
<div>[1] rbenchmark_1.0.0 stringr_0.6.1 data.table_1.8.6 RMySQL_0.9-3 DBI_0.2-5 </div><div><br></div><div>loaded via a namespace (and not attached):</div><div>[1] plyr_1.7.1 tools_2.15.2</div><div><br></div>
<div>## SYSTEM 2: </div><div>> sessionInfo()</div><div>R version 2.15.1 (2012-06-22)</div><div>Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)</div><div><br></div><div>locale:</div><div>[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8</div>
<div><br></div><div>attached base packages:</div><div>[1] stats graphics grDevices utils datasets methods base </div><div><br></div><div>other attached packages:</div><div>[1] data.table_1.8.6</div><div>> </div>
</div><div><br></div>