[R] looping with a dynamic variable

From: Abi Ghanem josephine <josephine.abighanem_at_ibpc.fr>
Date: Tue, 26 Feb 2008 17:01:16 +0100

i am trying to do a small job but it's bugging and i don't know what's happening.

let's say i have four matrix, M01_a, M02_a, M01_b, M02_b that looks like this
col1 col2

1         20
2         25
3         26
4          30
5         35
6         64
7         75
8         80
9         85

and a big matrix m:(21044*18)

what i want to do is
m1<- rbind(m[M01_a[,2],], m[M01_b[,2],]) m2 <- rbind(m[M02_a[,2],], m[M02_b[,2],])

the best will be to integrate this in a loop, so i just did this for (i in 1:2){
mb<- rbind(m[paste("M0",i,"_a[,2]", sep=""),], m[paste("M0",i,"_b[,2]", sep=""),])

but this didn't work :-(
i've been tring the whole afternoon , plz some help.


R-help_at_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. Received on Tue 26 Feb 2008 - 16:06:43 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 26 Feb 2008 - 16:30:17 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive