[R] creating list with 200 identical objects

Rainer M Krug r.m.krug at gmail.com
Mon Jun 1 12:08:31 CEST 2009


Hi

I am doing an simulation, and I a large proportion of the simulation
time is taken up by memory allocations.

I am creating an object, and storing it in a list of those objects.

essentially:

x <- list()
for (t in 1:500) {
 x[1] <- new("track")
}

I would like to initialize in one go, to avoid the continuous
reallocation of memory when a new "track" is added, and fill it wit
the object created by new("track").

How can I do this?

thanks

Rainer


-- 
Rainer M. Krug, Centre of Excellence for Invasion Biology,
Stellenbosch University, South Africa




More information about the R-help mailing list