[datatable-help] Magrittr + Data.table = Invalid .internal.selfref detected

rodonn rodonn at stanford.edu
Mon Feb 29 03:50:08 CET 2016


Here's a simple example that can reproduce the error.

require(data.table)
require(magrittr)
require(dplyr)

data(cars)
setDT(cars)

cars %<>% filter(Cylinder == 6) %>% setDT
cars[, DollarsPerMiles := Price / Mileage]

This generates the error:
Warning message:
In `[.data.table`(cars, , `:=`(DollarsPerMiles, Price/Mileage)) :
  Invalid .internal.selfref detected and fixed by taking a (shallow) copy of
the data.table so that := can add this new column by reference. At an
earlier point, this data.table has been copied by R (or been created
manually using structure() or similar). Avoid key<-, names<- and attr<-
which in R currently (and oddly) may copy the whole data.table. Use set*
syntax instead to avoid copying: ?set, ?setnames and ?setattr. Also, in
R<=v3.0.2, list(DT1,DT2) copied the entire DT1 and DT2 (R's list() used to
copy named objects); please upgrade to R>v3.0.2 if that is biting. If this
message doesn't help, please report to datatable-help so the root cause can
be fixed.


It seems like this either magrittr or dplyr is making an improper copy. I
know that there is a way of doing this sort of filtering using the
data.table syntax, but I find the dplyr syntax easier for certain
manipulations.

Thanks!



--
View this message in context: http://r.789695.n4.nabble.com/Magrittr-Data-table-Invalid-internal-selfref-detected-tp4717983.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list