【问题标题】:How to exclude rows from dataframe that match rows in same column of another dataframe? [duplicate]如何从数据框中排除与另一个数据框同一列中的行匹配的行? [复制]
【发布时间】:2021-12-12 09:34:48
【问题描述】:

所以我想过滤掉第二个数据集中也存在的第一个数据帧中的某些行。下面的命令没有生成我想要的数据框。

newdf <- filter(df1, df1$organization_name != df2$organization_name)

有没有其他可行的方法?

【问题讨论】:

标签: r dataframe dplyr data-manipulation


【解决方案1】:

试试这个:

newdf <- filter(df1, !df1$organization_name %in% df2$organization_name)

###or using the pipe command:

newdf <- df1 %>%
filter(!df1$organization_name %in% df2$organization_name)

有些人更喜欢上述建议的“反加入”功能更简单并且可以解决问题

【讨论】:

  • 它有效,谢谢!
猜你喜欢
  • 2020-04-19
  • 2022-01-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多