Filtering joins filter rows from x based on the presence or absence of matches in y:
semi_join() return all rows from x with a match in y.
anti_join() return all rows from x without a match in y.
# "Filtering" joins keep cases from the LHS
band_members %>% semi_join(band_instruments)
#> Joining, by = "name"
#> # A tibble: 2 x 2
#> name band
#> <chr> <chr>
#> 1 John Beatles
#> 2 Paul Beatles
band_members %>% anti_join(band_instruments)
#> Joining, by = "name"
#> # A tibble: 1 x 2
#> name band
#> <chr> <chr>
#> 1 Mick Stones
请发表评论