【问题标题】:remove rows if it is negative number如果为负数,则删除行
【发布时间】:2016-02-05 17:22:18
【问题描述】:

如果我的 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

【问题讨论】:

  • @AvinashRaj 在 r/regex 中回答了这么多 regex 问题后拿起了一些 r? :}
  • @rawr ya,我知道基本的r ..如果我有时间,我应该完全参与这个标签。

标签: r dataframe row


【解决方案1】:

试试这个:

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

【讨论】:

    【解决方案2】:

    试试下面的代码:

    sample = sample[sample['A'] >= 0 ]
    

    【讨论】:

      猜你喜欢
      • 2022-12-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-18
      • 1970-01-01
      • 2018-08-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多