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
Post a Comment