I have two tables and I need to find how to get all the rows that are not existing in both tables.
Table A:
customer_id
01
02
03
04
05
06
Table B
customer_id
02
03
06
Result expected
customer_id
01
04
05
I have two tables and I need to find how to get all the rows that are not existing in both tables.
Table A:
customer_id
01
02
03
04
05
06
Table B
customer_id
02
03
06
Result expected
customer_id
01
04
05
library(dplyr)
A <- tibble(customer_id = c("01", "02" ,"03", "04", "05", "06"),
feature = letters[1:6])
B <- tibble(customer_id = c("02", "03", "06"),
feature = LETTERS[c(15,16,18)])
anti_join(A, B, by = "customer_id")
# A tibble: 3 × 2
customer_id feature
<chr> <chr>
1 01 a
2 04 d
3 05 e
Base R
A[!A$customer_id %in% B$customer_id,]
Output:
customer_id feature
<chr> <chr>
1 01 a
2 04 d
3 05 e