Answered by : mathiasf
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
Source : https://honingds.com/blog/dplyr-rename/ | Last Update : Sun, 28 Jun 20
Answered by : scary-swan-7thuwiformdo
colnames(trSamp)[2] <- "newname2"
Source : https://stackoverflow.com/questions/7531868/how-to-rename-a-single-column-in-a-data-frame | Last Update : Tue, 26 May 20
Answered by : mathiasf
my_data %>% rename( sepal_length = Sepal.Length, sepal_width = Sepal.Width )
Source : https://www.datanovia.com/en/lessons/rename-data-frame-columns-in-r/ | Last Update : Tue, 02 Jun 20
Answered by : strange-snake-orraarca0ghn
library(plyr)
rename(d, c("beta"="two", "gamma"="three"))
#> alpha two three
#> 1 1 4 7
#> 2 2 5 8
#> 3 3 6 9
Source : http://www.cookbook-r.com/Manipulating_data/Renaming_columns_in_a_data_frame/ | Last Update : Wed, 01 Apr 20
Answered by : comfortable-cow
# df = dataframe
# old.var.name = The name you don't like anymore
# new.var.name = The name you want to get
names(df)[names(df) == 'old.var.name'] <- 'new.var.name'
Source : https://stackoverflow.com/questions/7531868/how-to-rename-a-single-column-in-a-data-frame | Last Update : Thu, 05 Mar 20
Answered by : andrea-perlato
colnames(df)[which(names(df) == "columnName")] <- "newColumnName"
Source : https://stackoverflow.com/questions/6081439/changing-column-names-of-a-data-frame | Last Update : Thu, 30 Jul 20