[R] Select subset of data

Lisa lisajca at gmail.com
Tue Mar 29 21:40:06 CEST 2011


Dear All,

I have a dataset that looks like this:

   group subject result v4 v5 
1      1       1      0  1  0 
2      1       2      1  0  0 
3      1       3      0  0  0 
4      1       4      1  0  0 
5      2       1      0  1  1 
6      2       2      0  0  1 
7      2       3      0  1  1 
8      3       1      0  1  0 
9      3       2      0  0  1 
10     3       3      1  0  0 
11     3       4      0  1  0 
12     4       1      1  0  0 
13     4       2      1  1  0 
14     4       3      0  0  1 
15     4       4      0  0  0 
16     4       5      1  0  1
……

I only show 4 groups here. There are several subjects within each group. I
want to select some groups in which for the firs two subjects, the results
are equal to 0, and for the other subjects, only one has the result being
equal to 1. So, for the data above, only the group 3 satisfies these
conditions. Therefore, the new dataset is:

   group subject result v4 v5 
8       3         1      0    1  0 
9       3         2      0    0  1 
10     3         3      1    0  0 
11     3         4      0    1  0 

Can anybody please help how to get this done? Your help would be greatly
appreciated. 

Lisa


--
View this message in context: http://r.789695.n4.nabble.com/Select-subset-of-data-tp3416012p3416012.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list