chnames | R Documentation |
This function replaces the variable names in a data.frame
chnames(object, old_variable_name, new_variable_name)
object |
a data frame |
old_variable_name |
a character vector with old variables names |
new_variable_name |
a character vector with new variables names |
object
Cedric Briand cedric.briand@eptb-vilaine.fr
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.