R: Search through multiple columns if value is present keep that row -


what want if search through each second column , if, within row, 1 column has value greater 0.95 keep it. ever row retained must have @ least 1 column >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 want go through 'decetionscore_' columns , values greater 0.95 above 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 have attempt is

newdf<-df[df[,(seq(3,151,2)] >= 0.95,]  ## col 1 ids 

any ideas how approach this?

df2 = df[which(apply(df[,seq(3,151,2)], 1, max) > 0.95),] 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -