I have a data like this:
+---+----+----+----+------+
| Su| Re | BM | CH | Eyes |
+---+----+----+----+------+
| 1 | 1 | . | 0 | 0 |
| 0 | 1 | 1 | 0 | 1 |
| 1 | 1 | 2 | . | 0 |
| 0 | 1 | 3 | 1 | 1 |
| 1 | 2 | . | 0 | 0 |
| 0 | 2 | 2 | 0 | 1 |
| 1 | 2 | 3 | . | 1 |
| 0 | 2 | 4 | 1 | 1 |
+---+----+----+----+------+
I am trying to create multiple vectors based on this criteria Su=1 and Re =1,2,3...., Su=1 and Re=1 first data vector, Su=1 and Re=3 second vector so on....I am using a loop for iterating through Re and subsetting dataset based on Su and Re. This is my code below, its not working, i need help to find out where I am going wrong.
library(foreign)
a <- read.dta(".....Data.dta")
for (i in 1:10)
{
b[i,]=subset(a, su==1 & re==i)
}
b