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
  • 12,918
  • 18
  • 86
  • 153

0 Answers0