chnames {stacomirtools} | R Documentation |
This function replaces the variable names in a data.frame
Description
This function replaces the variable names in a data.frame
Usage
chnames(object, old_variable_name, new_variable_name)
Arguments
object |
a data frame |
old_variable_name |
a character vector with old variables names |
new_variable_name |
a character vector with new variables names |
Value
object
Author(s)
Cedric Briand cedric.briand@eptb-vilaine.fr
Examples
df <- data.frame("var1" = c("blue","red"), "var2" = c("nice","ugly"))
colnames(df) # "var1" "var2"
df <- chnames(object = df, old_variable_name = c("var1","var2"),
"new_variable_name" = c("color","beauty"))
colnames(df) # "color" "beauty"
# the following will return an error, as the variable wrong_name is not in variable names
## Not run:
chnames(object = df, old_variable_name = c("wrong_name"),
"new_variable_name" = c("color")))
## End(Not run)
[Package stacomirtools version 0.6.0.1 Index]