如果是负数,则删除行

时间:2015-11-05 01:09:47

标签: r dataframe row

如果我的data.frame看起来像:

   A     B       C
1 10 James    Math
2 -1  Tony Science
3 -5 Kevin    Math
4 11 Chris    Math
5 13   Min English

如果A的值为负数,我想删除行 像这样:

   A     B       C
1 10 James    Math
4 11 Chris    Math
5 13   Min English

2 个答案:

答案 0 :(得分:7)

试试这个:

df <- df[df$A >= 0, ]

答案 1 :(得分:0)

试试下面的代码:

sample = sample[sample['A'] >= 0 ]
相关问题