如何使这些行保持特定的阈值

时间:2016-05-12 16:30:57

标签: r

我的数据看起来像这样

df<- structure(list(V1 = structure(c(6L, 2L, 3L, 7L, 5L, 4L, 8L, 1L
), .Label = c("A0A0G2JDV6", "P01901", "P13745", "Q03141", "Q3TMK4", 
"Q3UCW4", "Q8CBE6", "Q8VCQ8"), class = "factor"), V2 = c(1.234548336, 
0.982968881, 1.521367521, 1.00623053, 0.868106341, 1.035714286, 
0, 2.436170213), V3 = c(1.185419968, 1.131202691, 1.558404558, 
0.775700935, 0.74580573, 0.897230321, 0, 2.686170213), V4 = c(1.0681458, 
1.08999159, 1.715099715, 0.943925234, 0.774627893, 0.927842566, 
0, 2.287234043), V5 = c(1.535657686, 1.25862069, 2.068376068, 
1.012461059, 0.828314549, 1.04664723, 0, 2.579787234), V6 = c(1.605388273, 
1.280277544, 1.792022792, 0.875389408, 0.828357567, 1.183673469, 
0, 2.558510638)), .Names = c("V1", "V2", "V3", "V4", "V5", "V6"
), class = "data.frame", row.names = c(NA, -8L))

我想选择那些至少有两个大于或等于1.1的值的行

1 个答案:

答案 0 :(得分:1)

您可以根据满足条件的列的行总和进行子集化:

df[rowSums(df[,2:6] >= 1.1) >= 2,]

          V1        V2       V3       V4       V5       V6
1     Q3UCW4 1.2345483 1.185420 1.068146 1.535658 1.605388
2     P01901 0.9829689 1.131203 1.089992 1.258621 1.280278
3     P13745 1.5213675 1.558405 1.715100 2.068376 1.792023
8 A0A0G2JDV6 2.4361702 2.686170 2.287234 2.579787 2.558511