删除值小于R中的行

sbr*_*bio 3 r dataframe

我在R中有df

    sample1 sample2 sample3 sample4
price1  10  21  32  43
price2  12  24  15  18
price3  1   2   15  8
price4  16  30  44  58
price5  18  33  48  63
price6  20  36  52  68
price7  22  39  56  73
price8  24  42  60  78
price9  26  45  64  83
price10 28  48  68  88
Run Code Online (Sandbox Code Playgroud)

我想执行一个操作,希望在多于2列中删除值小于15的行

所以

price3  1   2   15  8
Run Code Online (Sandbox Code Playgroud)

将被删除

akr*_*run 6

我们可以rowSums用来创建逻辑向量

df1[rowSums(df1 < 15) <=2 , , drop = FALSE]
#        sample1 sample2 sample3 sample4
#price1       10      21      32      43
#price2       12      24      15      18
#price4       16      30      44      58
#price5       18      33      48      63
#price6       20      36      52      68
#price7       22      39      56      73
#price8       24      42      60      78
#price9       26      45      64      83
#price10      28      48      68      88
Run Code Online (Sandbox Code Playgroud)