rename_variable {capl} | R Documentation |
Rename variables in a data frame.
Description
This function renames variables in a data frame.
Usage
rename_variable(x = NULL, search = NA, replace = NA)
Arguments
x |
A data frame. |
search |
A character vector representing the variable names to be renamed. |
replace |
A character vector representing the new names for those variables identified in the |
Details
Other capl
functions called by this function include: validate_character()
.
Value
Returns a data frame with the renamed variables (if variables in the search
argument are successfully found and renamed).
Examples
capl_demo_data <- get_capl_demo_data(n = 25)
str(capl_demo_data[, 1:2])
# 'data.frame': 25 obs. of 2 variables:
# $ age : int 11 9 10 11 9 8 11 9 10 12 ...
# $ gender: chr "Female" "Girl" "Girl" "f" ...
capl_demo_data <- rename_variable(
x = capl_demo_data,
search = c("age", "gender"),
replace = c("hello", "world")
)
str(capl_demo_data[, 1:2])
# 'data.frame': 25 obs. of 2 variables:
# $ hello: int 11 9 10 11 9 8 11 9 10 12 ...
# $ world: chr "Female" "Girl" "Girl" "f" ...
[Package capl version 1.42 Index]