[R] storing objects (lm results) in an array

Jason Turner jasont at indigoindustrial.co.nz
Wed Sep 24 19:50:20 CEST 2003


On Thu, 2003-09-25 at 05:34, Christoph Lehmann wrote:
> Hi
> 
> I have calculated lots (>1000) of linear models and would like to store
> each single result as an element of a 3D matrix or a similar storage:
> something like
> 
> glm[i][j][k] = lm(...)
> 
> Since I read that results are lists: Is it possible to define a matrix
> of type list? 
> 
> Or what do you recommend?

1) glm is already a function name in R.  I'd suggest a different name.

2) I don't recommend a matrix.  Matricies require contiguous memory
chunks - it's possible to not have a long enough "block" of memory
available, even when the total free memory is sufficient, when storing
large matricies.

What's wrong with nested lists?  Something like my.lms[[i]][[j]][[k]] <-
lm(...)

This can "scatter" its storage across discontinuous chunks of memory.

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
+64-(0)21-343-545




More information about the R-help mailing list