rn_cols: Setting column names

View source: R/rn_cols.R

rn_colsR Documentation

Setting column names

Description

using data.table packages setnames function to change column names

Usage

rn_cols(dt, old=NULL, new=NULL, ...)

Arguments

dt

input data.table

old

default = NULL vector of existing column names

new

default = NULL vector of new column names

...

non-standard evaluation of in the form of an expression such as, old_column_name = new_column_name

Details

User can use provide a vector of characters for current column names and a vector of characters of equal lengths as new column names. Alternatively, user can also use the old_column_name=new_column_name notation, separated by comma.

Examples

## Not run: 
rn_cols(dt, hp=horsepower, disp=displacement)
rn_cols(dt, old=c("hp", "disp", "cyl"), new=c("horsepower", "displacement", "cylinder"))

## End(Not run)

kleu046/wr.data.table documentation built on April 25, 2022, 1:41 p.m.