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 nest_rename(): Use new_name = old_name to rename selected variables.

For nest_rename_with(): additional arguments passed onto .fn.

.fn

A function used to transform the selected .cols. Should return a character vector the same length as the input.

.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:

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)

[Package nplyr version 0.2.0 Index]