[R] 1.8.1 behavior change?

Duncan Murdoch dmurdoch at pair.com
Sat Nov 22 23:10:39 CET 2003


On Sat, 22 Nov 2003 15:14:31 -0500 (EST), you wrote:

>
>I would like to have one handle or reference to
>'n' matrices. The matrices vary in size.
>All data is floating point.
>The input files have 21 columns and a varying
>number of rows.
>
>I am open to any data structure that will
>support this.

Why not store them in a list, e.g.

> stt <- list()
> for (i in 1:3) stt[[i]] <- matrix(i, i, i)
> 
> stt
[[1]]
     [,1]
[1,]    1

[[2]]
     [,1] [,2]
[1,]    2    2
[2,]    2    2

[[3]]
     [,1] [,2] [,3]
[1,]    3    3    3
[2,]    3    3    3
[3,]    3    3    3

There are no restrictions on the shapes of the matrices that can be
stored this way.  You access matrix i entry (j,k) as stt[[i]][j,k].

Duncan Murdoch




More information about the R-help mailing list