Использование anti_join
, которое в основном сохраняет только строки в df1
, а не в df2
:
library(dplpyr)
df1 %>%
anti_join(df2, by = "BatchNo.")
# Joining, by = "BatchNo." # be sure that "BatchNo." is spelled the same
# Month Place BatchNo. Passed
# 1 MAR CAN 14824 N
# 2 OCT GER 15842 Y
# 3 JUL POR 13654 N
Данные:
tt <- "Month Place BatchNo. Passed
FEB NZ 12451 Y
MAR CAN 14824 N
OCT GER 15842 Y
JUL POR 13654 N
MAY ESP 12445 N"
df1 <- read.table(text=tt, header = T)
tt <- "BatchNo. Commodity Price
12451 BUS 100
12445 CAR 200"
df2 <- read.table(text=tt, header = T)