Here is a very light example of what I want to do.
test <- data.table(a=c(1,2,3),b=c(4,5,6))
f1 <- function(){
test2 <- data.table(a=c(4,5,6),b=c(1,2,3))
test <- copy(test2)
}
f1()
> test
a b
1: 1 4
2: 2 5
3: 3 6
I would like to copy test2
into test
by reference directly into the function f1()
so that the output would be
> test
a b
1: 4 1
2: 5 2
3: 6 3
I know that <-
is making a copy, I would like to do the same, copying a data.table, but by reference. Is there a way to make that possible?
Thanks all!