Below are the different methods for renaming columns in R-studio tool. Each method uses different libraries. You can follow any one method as per convenience..

DEMO:

Below are the old and new column details:

 

METHOD -1:( using Library : dplyr )

  • To rename single column:
---  Syntax  
DF %>% Rename ("New name" = "Old Name")

--- Example:
DF %>% Rename ("Column_1" = "Column_One")
  • To rename Multiple column:
--- Syntax  
	DF %>% Rename ("New name1" = "Old Name1","New name2" = "Old Name2","New name1" = "Old Name1")

--- Example:
 	DF %>% Rename ("Column_1" = "Column_One", "Column_2" = "Column_Two", "Column_3" = "Column_Three")

Method -2 ( Using Library : data.table )

  • To rename singel column:
--- Syntax  
DF=setname(x=df,old=("Old Name"),New=c("New Name"))

--- Example:
DF=setname(x=df,old=("Column_One"),New=c("Column_1"))
  • To rename Multiple column:
--- Syntax 
DF=setname(x=df,old=("Old Name1","Old Name2", "Old Name3"),New=c("New Name1","New Name2", "New Name3"))

--- Example:
DF=setname(x=df,old=("Column_One","Column_Two", "Column_Three"),New=c("Column_1","Column_2", "Column_3"))