change_var_names: Change variable names in a data set

View source: R/change_var_names.R

change_var_namesR Documentation

Change variable names in a data set

Description

Change variable names in a data set

Usage

change_var_names(
  data = NULL,
  old_var_names = NULL,
  new_var_names = NULL,
  skip_absent = FALSE,
  print_summary = TRUE,
  output_type = "dt"
)

Arguments

data

a data object (a data frame or a data.table)

old_var_names

a vector of old variable names (i.e., variable names to change)

new_var_names

a vector of new variable names

skip_absent

If skip_absent = TRUE, old variable names that do not exist in the data set will be skipped (default = TRUE).

print_summary

If print_summary = TRUE, a summary of old and new variable names will printed. (default = TRUE)

output_type

type of the output. If output_type = "dt", the function's output will be a data.table with changed names. If output_type = "summary", the function's output will be a data.table listing old and new variable names. By default, output_type = "dt".

Value

a data.table object with changed variable names

Examples

change_var_names(
mtcars, old = c("mpg", "cyl"), new = c("mpg_new", "cyl_new"))

kim documentation built on Oct. 9, 2023, 5:08 p.m.