| filter_joins | R Documentation |
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.
anti_join(x, y, by = NULL, copy = FALSE, ..., na_matches = c("na", "never"))
semi_join(x, y, by = NULL, copy = FALSE, ..., na_matches = c("na", "never"))
x, y |
The |
by |
A character vector of variables to join by. If To join by different variables on x and y use a named vector. For example, |
copy |
Ignored. Included for compatibility with |
... |
Ignored. Included for compatibility with |
na_matches |
Should The default, Use |
table1 <- data.frame(
pupil = rep(1:3, each = 2),
test = rep(c("A", "B"), 3),
score = c(60, 70, 65, 80, 85, 70),
stringsAsFactors = FALSE
)
table2 <- table1[c(1, 3, 4), ]
table1 %>% anti_join(table2, by = c("pupil", "test"))
table1 %>% semi_join(table2, by = c("pupil", "test"))
sensors <- data.frame(site = c("north", NA, "south"), reading = c(4.2, 3.9, 5.1))
sites <- data.frame(site = c("north", NA))
semi_join(sensors, sites, by = "site")
semi_join(sensors, sites, by = "site", na_matches = "never")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.