[R] dynamic object names?

samir@guidi.ch samir at guidi.ch
Mon Sep 19 11:27:14 CEST 2005


I am trying to extract data from a matrix. Let's say that i am interested in
extracting 
rows from a 4x4 matrix. Instead of giving a fix name to these 4 rows I would
like to add a number to prefix. As result I should get 4 objects named: 

prefix_1 
prefix_2 
prefix_3
prefix_4

I attepted to solve the problem with a loop, but without success. Any hints??

> matrix(LETTERS[1:16], ncol=4) -> MM
> MM
     [,1] [,2] [,3] [,4]
[1,] "A"  "E"  "I"  "M" 
[2,] "B"  "F"  "J"  "N" 
[3,] "C"  "G"  "K"  "O" 
[4,] "D"  "H"  "L"  "P" 


for (xxx in 1:4) {
MM[xxx,] -> prefix_xxx;
}


Thanks

samir




More information about the R-help mailing list