how to rename data in r code example
Example 1: rename columns based on a variable in r
df <- rename(df, new_name = old_name) #For renaming dataframe column
tbl <- rename(tbl, new_name = old_name) #For renaming tibble column
tbl <- tbl %>% rename(new_name = old_name) #For renaming tibble column using dplyrpipe
#operator
Example 2: r: rename a column
colnames(df)[which(names(df) == "columnName")] <- "newColumnName"