Let's say this is my dataframe:
df <- data.frame(replicate(10,sample(0:50,20,rep=TRUE)))
S X1 X2 X3 X4 X5 X6 X7 X8 X9 X10
1 3 26 39 25 24 4 46 42 8 42
2 40 6 50 50 22 2 40 24 26 17
3 32 45 18 7 19 6 33 12 0 13
4 3 45 43 32 16 33 25 18 35 45
5 7 36 2 25 16 20 24 14 27 29
6 45 4 12 13 50 35 38 1 27 34
7 18 43 38 16 34 18 19 45 4 34
8 18 9 33 38 18 13 23 44 41 4
9 28 34 6 3 14 11 47 4 21 50
10 6 48 42 46 48 42 12 33 1 32
11 28 20 37 2 26 33 5 2 22 27
12 40 30 41 45 28 6 5 46 21 46
13 1 47 46 37 0 3 11 45 12 11
14 20 0 9 38 42 15 44 1 2 45
15 49 29 25 41 38 26 20 34 50 0
16 2 5 47 6 36 34 28 36 32 38
17 15 22 50 13 26 9 37 40 41 23
18 44 27 47 37 26 34 31 36 44 12
19 47 41 19 2 50 44 48 36 34 38
20 25 31 28 34 8 19 3 13 14 23
I need to exclude subjects ('S') with values higher than 30 in 8 or more columns(X1:X10). That is, only exclude those who has 8 times or more values above 30 (e.g. Subject 19). I was thinking that maybe 'ifelse' function can be useful, but I really don't know how to implement it.
Any help is highly appreciated! Thanks a lot!
Aucun commentaire:
Enregistrer un commentaire