nest_rename {nplyr} | R Documentation |
Rename columns in nested data frames
Description
nest_rename()
changes the names of individual variables using
new_name = old_name
syntax; nest_rename_with()
renames columns using a
function.
Usage
nest_rename(.data, .nest_data, ...)
nest_rename_with(.data, .nest_data, .fn, .cols = dplyr::everything(), ...)
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 |
... |
For For |
.fn |
A function used to transform the selected |
.cols |
Columns to rename; defaults to all columns. |
Details
nest_rename()
and nest_rename_with()
are largely wrappers for
dplyr::rename()
and dplyr::rename_with()
and maintain the functionality
of rename()
and rename_with()
within each nested data frame. For more
information on rename()
or rename_with()
, 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.
Column names are changed; column order is preserved.
Data frame attributes are preserved.
Groups are updated to reflect new names.
See Also
Other single table verbs:
nest_arrange()
,
nest_filter()
,
nest_mutate()
,
nest_select()
,
nest_slice()
,
nest_summarise()
Examples
gm_nest <- gapminder::gapminder %>% tidyr::nest(country_data = -continent)
gm_nest %>% nest_rename(country_data, population = pop)
gm_nest %>% nest_rename_with(country_data, stringr::str_to_lower)