Hm didn't know about the abind package. That is pretty sweet. I do often opt for the 'list of matrices' myself though because I'm more familiar with the methods for lists...
To answer one of Gundala's questions directly (assuming list of matrices is acceptable): Since you can do this, > x <- list() > x[["a"]] <- 1 > x[["b"]] <- 2 > x $a [1] 1 $b [1] 2 You should be able to do this as well: all_mat <- list() for (matno in 1:10) { all_mat[[paste("mat",matno,sep="")]] <- process_to_create_matrix(da[matno]) } and refer to mat$mat_no etc. ----- Original Message ---- From: Bert Gunter <[EMAIL PROTECTED]> To: Erik Iverson <[EMAIL PROTECTED]>; Gundala Viswanath <[EMAIL PROTECTED]> Cc: [EMAIL PROTECTED] Sent: Thursday, July 31, 2008 7:56:49 PM Subject: Re: [R] Storing Matrices into Hash R also has arrays (?array). If all the matrices are the **same dimension** and **same mode** (i.e. all numeric or all character), this is perhaps easier, especially if you want to access various "pieces" of your matrices. Given existing matrices, mat1, mat2,..., the slightly tricky way to combine them into an array is: your_array <- array(c(mat1,mat2,..),dim=c(dim(mat1,n)) ## where n is the number of matrices. This is slightly tricky because you have to understand that matrices are actually vectors in column major order with a "dim" attribute. An easier way to do it is to install the abind package from CRAN and just do your_array <- abind(mat1,mat2, ..., along =3) Accessing the matrices is then easy using array indexing. Again, this is only possible if they're all the same dimension. Otherwise Erik's approach must be used. I recommend that you spend some time learning about R's data structures. R's internal documentation, especially An Intro to R, is a good starting point, but there are now many books, both in English and other major European languages, out there to help you. The CRAN website lists many of them. Cheers, Bert Gunter Genentech, Inc. -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erik Iverson Sent: Thursday, July 31, 2008 7:01 PM To: Gundala Viswanath Cc: [EMAIL PROTECTED] Subject: Re: [R] Storing Matrices into Hash I think a named list is probably the easiest way to start off, something like: all_mat <- list(mat1 = mat1, mat2 = mat2) all_mat$mat2 Gundala Viswanath wrote: > Hi, > > Suppose I have these two matrices (could be more). > What I need to do is to store these matrices into a hash. > > So that I can call back any of the matrix back later. > > Is there a way to do it? > >> mat_1 > [,1] [,2] > [1,] 9.327924e-01 0.067207616 > [2,] 9.869321e-01 0.013067929 > [3,] 9.892814e-01 0.010718579 > [4,] 9.931603e-01 0.006839735 > [5,] 9.149056e-01 0.085094444 > >> mat_2 > [,1] [,2] > [1,] 9.328202e-01 0.067179769 > [2,] 9.869402e-01 0.013059827 > [3,] 9.892886e-01 0.010711437 > [4,] 9.931660e-01 0.006833979 > [5,] 9.149391e-01 0.085060890 > > > This method I have is not favorable > because it just stack the matrices together as another matrix. > Makes it hard to get individual matrix later. > > all_mat <- NULL > all_mat <- c(all_mat, mat1,mat2) > > > > - Gundala Viswanath > Jakarta - Indonesia > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.