[R] Embedding lists in matrices and matrices in lists
ggrothendieck at gmail.com
Tue Aug 18 12:02:03 CEST 2009
> m12 <- matrix(10, 1, 2)
> m22 <- matrix(20, 2, 2)
> # create matrix of lists of matrices
> M <- matrix(list(list(1, 2), list(m12, m12), list(t(m12)), list(m22, m22, m22)), 2, 2)
[1,] List,2 List,1
[2,] List,2 List,3
[1,] 10 10
[1,] 10 10
On Tue, Aug 18, 2009 at 4:48 AM, Michael Kogan<michael.kogan at gmx.net> wrote:
> I'm new to programming, new to R and even new to mailing lists so please be
> patient with me. I need to manage many matrices generated by an R program.
> These matrices have different dimensions and I'd like to group them somehow.
> The best way would be to have a big matrix (let's call it database) where
> every element database[x,y] consists of a list of matrices that all have the
> dimensions ncol(matrix1)=x and nrow(matrix1)=y. So those matrices have to be
> embedded into lists and the lists have to be embedded in the big database
> matrix. If I simply try
> I get
> Error in database[4, 4] = c(matrix1, matrix2) :
> number of items to replace is not a multiple of replacement length
> Execution halted
> which makes sense of course... Is there any possibility to make this work?
> Or maybe there is a better way to organize those matrices?
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help