how to change name of column in dataframe in r code example
Example 1: r change column name in dataframe
df <- df %>%
rename(newName1 = oldName1 ,
newName2 = oldName2)
Example 2: how to change column names in r
colnames(dataset) <- c('name1','name2',..)
Example 3: 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