[R] Transferring data from S+ to R
Simon Fear
fears at roycastle.liv.ac.uk
Mon Jan 18 11:10:19 CET 1999
In rw0631 I find that even the unsubscripted version does not hugely
increase workspace requirements - i.e. R *does* instantly clear out the
useless copies and make looping memory-feasible.
Apologies. I don't know if it's becuase I'm running a later version now,
or whether I made some stupid mistake last time I tried it.
Simon Fear
-----Original Message-----
From: Douglas Bates [mailto:bates at stat.wisc.edu]
Sent: 15 January 1999 14:56
To: Simon Fear
Cc: r-help at stat.math.ethz.ch; 'Jim Lindsey'
Subject: Re: [R] Transferring data from S+ to R
>>>>> "Simon" == Simon Fear <fears at roycastle.liv.ac.uk> writes:
Simon> Not that I have got it quite right yet though; I still
Simon> haven't worked out how to make, for example,
Simon> var1 <- rnorm(10000)
Simon> not create a new instance, eating 10000 globs of memory,
Simon> every time it is called within a loop;
I think if you make the construction look like
var1 <- double(10000)
for (i in 1:niter) {
var1[] <- rnorm(10000) # replacement rather than assignment
...
}
you avoid the multiple copies. I haven't tested this particular case
but the basic idea is that replacement of elements of a vector is done
in-place, if possible, and not be creating a new object. Assignment
to a name will usually result in a new object being created in a way
that masks the previous objects with that name.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
-.-.-.-
r-help mailing list -- Read
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.
_._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list