Gabriel Becker writes:
AFAIK R does not automatically copy function arguments. R actually tries
very hard to avoid copying while maintaining pass by value functionality.
... R only copies data when you modify an object, not
when you simply pass it to a function.
This is a bit
Also consider subsetting:
cat(a: ); print(system.time( { A - matrix(c(1.0,1.1),5,1000); 0 } ))
cat(h: ); print(system.time( { sum(A[1:5,1:1000]) } ))
cat(i: ); print(system.time( { sum(A[]) } ))
cat(j: ); print(system.time( { sum(A) } ))
In contrast with Python's NumPy array, the R array
Use tracemem() instead, i.e.
A - matrix(c(1.0,1.1), nrow=5, ncol=10);
tracemem(A);
[1] 0x047ab170
A[1,1] - 7;
B - sqrt(A);
tracemem[0x047ab170 - 0x0552f338]:
A[1,1] - 7;
B - t(A);
A[1,1] - 7;
tracemem[0x047ab170 - 0x057ba588]:
A[1,1] - 7;
A[1,1] -