[R] Storing Matrices into Hash
Erik Iverson
iverson at biostat.wisc.edu
Fri Aug 1 04:46:33 CEST 2008
Gundala Viswanath wrote:
> Thanks so much Erik,
>
> But how do you include that in a loop.
>
> I tried this, doesn't seem to work. Please advice:
>
> __BEGIN__
> all_mat <- NULL
>
> for (matno in 1:10) {
>
> mat <- process_to_create_matrix(da[matno])
> all_mat <- list(all_post, matno = mat)
>
> }
I'm not exactly sure what you're up to, what is all_post, and what is "da"?
You might look at the lapply function as an option for avoiding the loop
and writing cleaner code.
Something like:
all_mat <- lapply(da, process_to_create_matrix)
may or may not work depending on what "da" is.
Please see the footer of this message regarding reproducible,
self-contained example code.
Best,
Erik
More information about the R-help
mailing list