0

Possible Duplicate:
Writings functions (procedures) for data.table objects

I have a question concerning by-value/by-reference. data.table bring by-reference data.table<- and :=, but what about functions ?

DT <- data.table(a=c(1L,2L),b=c("foo","fii"));
f <- function(table){ table[,add:=1L]; }; 
f(DT); # would 0 or 1 copy of DT be performed here ?

R) DT
   a   b add
1: 1 foo   1
2: 2 fii   1

My understanding is that is using a function should imply a copy by value, but is it so ? Regards

Community
  • 1
  • 1
statquant
  • 13,672
  • 21
  • 91
  • 162
  • 1
    http://stackoverflow.com/a/13762050/1412059 – Roland Jan 11 '13 at 14:12
  • Can I humbly suggest adding information about by-reference `<-` and function in the vignette. I am happy to it myself if I can access the `.tex` – statquant Jan 11 '13 at 15:42
  • @statquant Absolutely. Click to join the project in R-Forge and then you can commit changes. Might move to github if it makes it easier for people to contribute. You'd be very welcome! – Matt Dowle Jan 11 '13 at 16:44

0 Answers0