Reputation: 903
What I want to do if search through each second column and if, within a row, one column has a value greater then 0.95 then keep it. Basically ever row retained must have at least one column that is >0.95. Example df:
Id VALUE_Sample1 DetectionScore_Sample1 VALUE_Sample2 DetectionScore_Sample2
1 10265 -0.251 0.8874 -0.1850 0.2120
2 10265 0.560 0.9989 0.6610 0.9456
3 12346 0.874 1.0000 0.7545 0.9900
So I want to go through the 'DecetionScore_' columns and look for any values greater the 0.95 so the above would return.
Id VALUE_Sample1 DetectionScore_Sample1 VALUE_Sample2 DetectionScore_Sample2
1 10265 0.560 0.9989 0.6610 0.9456
2 12346 0.874 1.0000 0.7545 0.9900
The code I have attempt is
newdf<-df[df[,(seq(3,151,2)] >= 0.95,] ## col 1 is IDs
Any ideas how I could approach this?
Upvotes: 2
Views: 2253