1

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
mgh
  • 71
  • 6

2 Answers2

4
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     

Acturio
  • 74
  • 5
0

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    
TarJae
  • 72,363
  • 6
  • 19
  • 66