rename_variable | R Documentation |
This function renames variables in a data frame.
rename_variable(x = NULL, search = NA, replace = NA)
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 |
Other capl
functions called by this function include: validate_character()
.
Returns a data frame with the renamed variables (if variables in the search
argument are successfully found and renamed).
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" ...
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.