| nest_relocate {nplyr} | R Documentation |
Change column order within a nested data frame
Description
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.
Usage
nest_relocate(.data, .nest_data, ..., .before = NULL, .after = NULL)
Arguments
.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 |
Details
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.
Value
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.
Examples
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)