Displaying 1 result from an estimated 1 matches for "t1all".
Did you mean:
t1call
2010 Mar 05
2
Selecting rows of a matrix based on some condition on the columns
...0 38.57 34.19 32.47
[9,] 87 35.22 0.00 0.00 35.31 0.00 0.00 34.55 35.14 38.12 0.00
[10,] 99 0.00 0.00 34.94 0.00 0.00 33.54 0.00 34.39 34.54 0.00
First, I wish to select for each row, all columns that have at least a T and a C. Based on the code below, I got exactly what I need.
> t1all <- apply(xy,1,function(x) any((x[2]>0|x[3]>0|x[4]>0|x[5]>0|x[6]>0)&(x[7]>0 |x[8]>0 |x[9]>0|x[10]>0|x[11]>0)))
> mat.t1all <- xy[t1all,]
> mat.t1all
x T1 T2 T3 T4 T5 C1 C2 C3 C4 C5
[1,] 50 0.00 0 33.75 0.00 0.00 0....