Re: [R] Why is vector assignment in R recreates the entire vector ?

2010-09-03 Thread Martin Maechler
> "NM" == Norm Matloff > on Thu, 2 Sep 2010 12:20:44 -0700 writes: NM> Tal wrote: >> A friend recently brought to my attention that vector assignment actually >> recreates the entire vector on which the assignment is performed. NM> ... NM> I brought this up in r-

Re: [R] Why is vector assignment in R recreates the entire vector ?

2010-09-02 Thread Norm Matloff
Tal wrote: > A friend recently brought to my attention that vector assignment actually > recreates the entire vector on which the assignment is performed. ... I brought this up in r-devel a few months ago. You can read my posting, and the various replies, at http://www.mail-archive.com/r-de...

Re: [R] Why is vector assignment in R recreates the entire vector ?

2010-09-01 Thread Duncan Murdoch
On 01/09/2010 11:09 AM, Tal Galili wrote: Hello all, A friend recently brought to my attention that vector assignment actually recreates the entire vector on which the assignment is performed. So for example, the code: x[10]<- NA # The original call (short version) Is really doing this: x<- re

Re: [R] Why is vector assignment in R recreates the entire vector ?

2010-09-01 Thread Matt Shotwell
Tal, For your first example, x is not duplicated in memory. If you compile R with --enable-memory-profiling, you have access to the tracemem() function, which will report whether x is duplicate()d: > x <- rep(1,100) > tracemem(x) [1] "<0x8f71c38>" > x[10] <- NA This does not result in duplicati

Re: [R] Why is vector assignment in R recreates the entire vector ?

2010-09-01 Thread Tal Galili
Thank you for the explanation Duncan - very interesting indeed! I wonder if someone in the list might know to answer your question regarding the double duplication. Best, Tal Contact Details:--- Contact me: tal.gal...@gmail.com

Re: [R] Why is vector assignment in R recreates the entire vector ?

2010-09-01 Thread Bert Gunter
On Wed, Sep 1, 2010 at 8:09 AM, Tal Galili wrote: > Hello all, > > A friend recently brought to my attention that vector assignment actually > recreates the entire vector on which the assignment is performed. > > So for example, the code: > x[10]<- NA # The original call (short version) > > Is rea

[R] Why is vector assignment in R recreates the entire vector ?

2010-09-01 Thread Tal Galili
Hello all, A friend recently brought to my attention that vector assignment actually recreates the entire vector on which the assignment is performed. So for example, the code: x[10]<- NA # The original call (short version) Is really doing this: x<- replace(x, list=10, values=NA) # The original