See Simon Urbanek's answer here (and Matt Dowle's Comments) http://stackoverflow.com/questions/15195220/assigning-by-reference-into-loaded-package-datasets/15208059#15208059 ________________________________________ From: [email protected] [[email protected]] on behalf of Steve Lianoglou [[email protected]] Sent: Friday, 18 April 2014 4:37 AM To: Michele Cc: [email protected] Subject: Re: [datatable-help] What is going on with R 3.1 ?
Hi, On Thu, Apr 17, 2014 at 10:15 AM, Michele <[email protected]> wrote: > If I try to copy() the tables to re-create the pointers all the tables get > the same one, always ending in 788 (opening another R session I get the same > result, same pointers accross the table, ending in 788): > >> dt <- readRDS("dt.RDS") >> dt1 <- readRDS("dt1.RDS") >> dput(copy(dt)) > structure(list(id = 1:5, var = c(-0.626453810742332, 0.183643324222082, > -0.835628612410047, 1.59528080213779, NA)), .Names = c("id", > "var"), row.names = c(NA, -5L), class = c("data.table", "data.frame" > ), .internal.selfref = <pointer: 0x00000000003e0788>) >> dput(copy(dt1)) > structure(list(id = 1:10, var2 = c(9.56605515060971, 9.83445938796679, > 9.14481066107107, 10.5308762543727, NA, NA, 9.45024506381369, > 10.0544601882071, 10.7019565371199, 9.60325830155958), var3 = > c(99.6542887323489, > 100.659231456233, 100.282028460177, 101.423474800432, 98.4134121985332, > NA, 98.0406472259105, 100.253194731594, 100.759881151841, 99.7930775536395 > )), .Names = c("id", "var2", "var3"), row.names = c(NA, -10L), class = > c("data.table", > "data.frame"), sorted = "id", .internal.selfref = <pointer: > 0x00000000003e0788>) Is this actually causing a problem for you somewhere? For instance, if you modify-by-reference "dt", like `dt[, z := 1]`, is `dt1` modified as well (it shouldn't be)? Let's try another experiment. Forget loading from an *.rds and just create a brand new data.table and look at its .internal.selfref: R> a <- data.table(a=1:10) R> b <- data.table(a=1:10) R> attributes(a)$.internal.selfref R> attributes(b)$.internal.selfref What do you see? Also, your initial post referenced two errors that both mentioned something about a missing logical value ("missing value where TRUE/FALSE needed"), but it's not clear what triggered the error. Have you been able to reproduce this? Next time this happens, can you call "traceback()" and provide the stack trace here? Also, your original post also said: > It's very unstable and I get different results time to time What is very unstable? And what results are different? What exact operations are you performing that are producing different results when you run them more than once? If you could provide a more precise explanation of what the problem is you are actually encountering via some piece of code that is producing the unexpected behavior you are observing, that would be most helpful. Thanks, -steve -- Steve Lianoglou Computational Biologist Genentech _______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help _______________________________________________ datatable-help mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
