简体   繁体   English

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

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

I have a data frame A of the below format Word Freq p 9531 can 2085 /p 2055 get 1183 use 1112 我有以下格式的数据帧A Word Freq p 9531 can 2085 /p 2055 get 1183 use 1112

and another data frame B 和另一个数据框B

Word Freq p 10 can 2 /p 55

Now I want to remove the rows from data frame A that has a matching in the data frame B. So my output would be for data frame A 现在,我想从数据帧A中删除与数据帧B中具有匹配项的行。因此,我的输出将是数据帧A的

Word Freq get 1183 use 1112

Do it this way: 这样做:

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),]

result: 结果:

  Word Freq
4  get 1183
5  use 1112

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

相关问题 如何基于R中不同数据框中的列值从一个数据框中删除行? - How to remove rows from one dataframe based on the column values in a different data frame in R? R:根据文件名列从数据框中删除行 - R: Remove rows from data frame based on file name column R如何根据列的第一个字符删除数据框中的行 - R how to remove rows in a data frame based on the first character of a column 如果指定列中有“,”,则从数据框中删除行 - Remove the rows from the data frame if there is “,” in specified column 如何从 R 中的数据框中删除指定行,但根据另一个列变量消除行? - How do I remove specified rows from a data frame in R, but the rows are eliminated according to another column variable? 如何从R数据框中的索引列获取唯一行 - How to get unique rows from the Index column in R data frame R如何从数据框中的长列名称中删除字符 - R How to remove characters from long column names in a data frame R 如何从数据框列中删除特殊字符 ’? - R How to remove special characters ’ from a data frame column? 如何在 dataframe 中插入与 R 中的数据帧长度不同的列 - How to insert column in dataframe with different length from data frame in R 从数据框中删除其列值与另一个数据框的列值不匹配的数据 - R - remove rows from data frame whose column values don't match another data frame's column values - R
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM