[R] extract rows based on column value in a data frame

Ragia Ibrahim ragia11 at hotmail.com
Wed Dec 2 19:09:16 CET 2015


Dear Group,
I have a data frame that such as

v1   v2    v3    v4
1      1      3      6
1      1       5     6
1       1      8     0
1       2      6     1
1       2      4     0
1       3      4      4
1       3      5      4
1       3      6      3
1       3      7      1

2       4      3      7
2       5       5     4
2       5      8     2
2       1      6     1
2       1      4     0
2      1      4      3
2       1      5      2
3       1      6      1
3       6      7      0

3      6       3      6
3      6       5      6
3      6       8      0
3      6       6      1
3      2       4      0
3      2       4      4
3      2       5      4
3      2       6      3
3      2       7      1
3       5       9      5
3       6       9       5   


the result required is each first 3 rows,  from distinct v2 column for each v1 column


v1   v2    v3    v4
1      1      3      6
1       2      6     1
1       3      4      4
2       4      3      7
2       5       5     4
2       1      6     1
3      6       3      6
3      2       4      0
3       5       9      5


thanks in advance 		 	   		  
	[[alternative HTML version deleted]]



More information about the R-help mailing list