繁体   English   中英

当列与R中的其他数据框列匹配时,如何从数据框中删除行

[英]How to remove rows from a data frame when the column matches with a different data frame column in R

我有以下格式的数据帧A Word Freq p 9531 can 2085 /p 2055 get 1183 use 1112

和另一个数据框B

Word Freq p 10 can 2 /p 55

现在,我想从数据帧A中删除与数据帧B中具有匹配项的行。因此,我的输出将是数据帧A的

Word Freq get 1183 use 1112

这样做:

A<-read.table(text="Word     Freq
p        9531
can      2085
/p       2055
get      1183
use      1112",header=T)

B<-read.table(text="Word     Freq
p        10
can      2
/p       55",header=T)

A[-which(A$Word %in% B$Word),]

结果:

  Word Freq
4  get 1183
5  use 1112

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM