[R] looping with a dynamic variable

Abi Ghanem josephine
Tue, 26 Feb 2008 16:01:16 -0000

Hi,
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.

thx,
josephine