[R] dynamic object names?

From: <samir_at_guidi.ch>
Date: Mon 19 Sep 2005 - 19:27:14 EST

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



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Sep 21 03:07:31 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:40:20 EST