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 call (long version) # assigning a whole new vector to x Which is actually doing this: x<- `[<-`(x, list=10, values=NA) # The actual call Assuming this can be explained reasonably to the lay man, my question is, why is it done this way ? Why won't it just change the relevant pointer in memory? On small vectors it makes no difference. But on big vectors this might be (so I suspect) costly (in terms of time). I'm curious for your responses on the subject. Best, Tal ----------------Contact Details:------------------------------------------------------- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) ---------------------------------------------------------------------------------------------- [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.