I am needing some help in removing certain rows in a data.matrix and then do
some calculation. So Iam need to removing certain values above a threshold
or value from another  vector.

For eg.. in the below data matrix X there are 6 groups (A, B, C, D, E ,F)

>X
rows    groups  values
1       A       1.2
2       A       0.2
3       A       6
4       A       0.5
5       A       22
6       B       0.2
7       B       1
8       C       0.5
9       D       5
10      D       4
11      D       40
12      E       0.3
13      E       0.5
14      E       1
15      E       1.1
16      E       0.9
17      E       4
18      F       0.22
19      F       0.32
20      F       1.5


I have another array  Y with 6 values (equal to the number of groups in X). 
I need to remove the rows in each group in X that is greater than the first
value in Y for Group A in X and similarly for group B and so on…..

>Y


A       1.5
B       1.1
C       0.8
D       6
E       2
F       1.9


For eg… any value greater than 1.5 (from vector Y) must be removed in Matrix
X  only for group A. similarly for all, hence the result will be like the
matrix shown below…

rows    groups  values
1       A       1.2
2       A       0.2
3       A       6
4       A       0.5
5       B       0.2
6       B       1
7       C       0.5
8       D       5
9       D       4
10      E       0.3
11      E       0.5
12      E       1
13      E       1.1
14      E       0.9
15      F       0.22
16      F       0.32
17      F       1.5


I tried to get this with no luck any help would be appreciated.

swam


-- 
View this message in context: 
http://r.789695.n4.nabble.com/removing-rows-from-a-matrix-using-condition-within-groups-tp3004132p3004132.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to