nest-filter-joins | R Documentation |
Nested filtering joins filter rows from .nest_data
based on the presence or
absence of matches in y
:
nest_semi_join()
returns all rows from .nest_data
with a match in y
.
nest_anti_join()
returns all rows from .nest_data
without a match in y
.
nest_semi_join(.data, .nest_data, y, by = NULL, copy = FALSE, ...) nest_anti_join(.data, .nest_data, y, by = NULL, copy = FALSE, ...)
.data |
A data frame, data frame extension (e.g., a tibble), or a lazy data frame (e.g., from dbplyr or dtplyr). |
.nest_data |
A list-column containing data frames |
y |
A data frame, data frame extension (e.g., a tibble), or a lazy data frame (e.g., from dbplyr or dtplyr). |
by |
A character vector of variables to join by or a join specification
created with If To join on different variables between the objects in To join by multiple variables, use a vector with length >1. For example,
To perform a cross-join, generating all combinations of each object in
|
copy |
If |
... |
One or more unquoted expressions separated by commas. Variable
names can be used if they were positions in the data frame, so expressions
like |
nest_semi_join()
and nest_anti_join()
are largely wrappers for
dplyr::semi_join()
and dplyr::anti_join()
and maintain the functionality
of semi_join()
and anti_join()
within each nested data frame. For more
information on semi_join()
or anti_join()
, please refer to the
documentation in dplyr
.
An object of the same type as .data
. Each object in the column .nest_data
will also be of the same type as the input. Each object in .nest_data
has
the following properties:
Rows are a subset of the input, but appear in the same order.
Columns are not modified.
Data frame attributes are preserved.
Groups are taken from .nest_data
. The number of groups may be reduced.
Other joins:
nest-mutate-joins
,
nest_nest_join()
gm_nest <- gapminder::gapminder %>% tidyr::nest(country_data = -continent) gm_codes <- gapminder::country_codes %>% dplyr::slice_sample(n = 10) gm_nest %>% nest_semi_join(country_data, gm_codes, by = "country") gm_nest %>% nest_anti_join(country_data, gm_codes, by = "country")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.