r rename df columns code example
Example 1: how to change column names in r
colnames(dataset) <- c('name1','name2',..)
Example 2: R rename singl edf column
colnames(trSamp)[2] <- "newname2"
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