change_var_names: Change variable names in a data set

Description Usage Arguments Value Examples

View source: R/change_var_names.R

Description

Change variable names in a data set

Usage

1
2
3
4
5
6
7
8
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

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

kim documentation built on April 25, 2021, 1:06 a.m.