[R] storing objects (lm results) in an array
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Wed Sep 24 22:27:27 CEST 2003
Jason Turner <jasont at indigoindustrial.co.nz> writes:
> 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.
Lists can have dimensions, so
lmarray <- array(list(),c(I,J,K))
works fine. E.g.
[,1] [,2] [,3] [,4] [,5]
[1,] NULL NULL NULL NULL NULL
[2,] NULL NULL NULL NULL NULL
Notice that this is not a matrix, though. At least not in the S4
sense, where the elements need to be of a base type for an object of
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help