rename_cols: Rename columns in a table

Description Usage Arguments Value Examples

View source: R/convenience.r

Description

Rename columns in a table

Usage

1
rename_cols(.tbl, .vars, strict = TRUE)

Arguments

.tbl

Table to rename

.vars

A named character vector, where the names are the new column names and the values are existing column names.

strict

Should the function raise an error if existing column names can't be found? (Default TRUE)

Value

The same .tbl, with some renamed columns

Note that this function is the same as colnames()<- for in-memory data.frames, but also works for remote tbls. It's similar to pandas' .rename method.

Examples

1
2
cols_to_rename <- c(cyl2 = "cyl")
rename_cols(mtcars, cols_to_rename)

karldw/kdw.junk documentation built on Sept. 8, 2021, 9:30 p.m.