[R] Deep copy in R
Thomas Lumley
tlumley at u.washington.edu
Tue Apr 6 16:29:38 CEST 2004
On Mon, 5 Apr 2004, Shin, Daehyok wrote:
> Hm. Smarter than I expected.
> But, any special reason why the 6th line clones another vector?
> To me, just reference copy seems to be enough for the purpose.
>
> 6 xf = date.frame(x=x)
>
You would have to look at the code for data.frame to see this, but I think
it does in fact copy. However, that should stop line 7 from having to
copy so it all works out in the end.
There may also be temporary copies made during data.frame(), which is a
much less straightforward piece of code than you might expect.
-thomas
More information about the R-help
mailing list