View source: R/nest_relocate.R
| nest_relocate | R Documentation |
nest_relocate() changes column positions within a nested data frame, using
the same syntax as nest_select() or dplyr::select() to make it easy to
move blocks of columns at once.
nest_relocate(.data, .nest_data, ..., .before = NULL, .after = NULL)
.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 |
... |
Columns to move. |
.before, .after |
Destination of columns selected by |
nest_relocate() is largely a wrapper for dplyr::relocate() and maintains
the functionality of relocate() within each nested data frame. For more
information on relocate(), 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 affected.
The same columns appear in the output, but (usually) in a different place.
Data frame attributes are preserved.
Groups are not affected.
gm_nest <- gapminder::gapminder %>% tidyr::nest(country_data = -continent)
gm_nest %>% nest_relocate(country_data, year)
gm_nest %>% nest_relocate(country_data, pop, .after = year)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.