nest_select | R Documentation |
nest_select()
selects (and optionally renames) variables in nested data
frames, using a concise mini-language that makes it easy to refer to
variables based on their name (e.g., a:f
selects all columns from a
on
the left to f
on the right). You can also use predicate functions like
is.numeric to select variables based on their properties.
nest_select(.data, .nest_data, ...)
.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 |
... |
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_select()
is largely a wrapper for dplyr::select()
and maintains the
functionality of select()
within each nested data frame. For more
information on select()
, 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 not affect.
Output columns are a subset of input columns, potentially with a different
order. Columns will be renamed if new_name = old_name
form is used.
Data frame attributes are preserved.
Groups are maintained; you can't select off grouping variables.
Other single table verbs:
nest_arrange()
,
nest_filter()
,
nest_mutate()
,
nest_rename()
,
nest_slice()
,
nest_summarise()
gm_nest <- gapminder::gapminder %>% tidyr::nest(country_data = -continent) gm_nest %>% nest_select(country_data, country, year, pop) gm_nest %>% nest_select(country_data, where(is.numeric))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.