【问题标题】:I want to filter rows by the content of their cells, with multiple words [duplicate]我想通过单元格的内容过滤行,包含多个单词[重复]
【发布时间】:2019-02-28 10:38:51
【问题描述】:

我有一张这样的桌子 enter image description here

我想过滤“Cellular”列中包含“membrane”一词的所有行。 但是当我这样做时,我只得到只有单词membrane的行,而不是任何其他单词。 帮助

【问题讨论】:

  • 仅供参考,我认为这被否决了,因为它不是一个可重复的示例 (stackoverflow.com/questions/5963269/…),它包含屏幕截图而不是文本数据,而且这也是一个肯定已被多次回答的问题之前。
  • 显示您尝试过的代码,以便我们帮助您修复它
  • 我试过 Base3
  • 用 Base3 搞定了

标签: r filter rows


【解决方案1】:

您可以使用带有grepl() 表达式的正则表达式来做到这一点:

dat <- data.frame(id = 1:4, Cellular = c("membrane", "membrane", "cytoplasm", "cellsurface;membrane"))

dat[grepl("membrane", dat$Cellular),]

#   id             Cellular
# 1  1             membrane
# 2  2             membrane
# 4  4 cellsurface;membrane

【讨论】:

    猜你喜欢
    • 2018-08-07
    • 2021-01-10
    • 1970-01-01
    • 2020-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-08
    • 2018-05-18
    相关资源
    最近更新 更多