I don't think you got a response to this one;
x <- array(dim=(c(j, n)))
for (i in 1:n) {
x[,i] <- rnorm(j)
}
Note that array() allocates a logical array by default, which means
that in your first iteration (i==1) it has to be coerced to a double
array before assigning the valu
The R Inferno advises that if you are building up results in pieces it's
best to pre-allocate the result object and fill it in. In some testing,
I see a benefit with this strategy for regular variables. However, when
the results are held by a class, the opposite seems to be the case.
Comments?
2 matches
Mail list logo