How to use Rename Method In R Language
The rename in the dplyr package is used to rename the name of any data frame column in R. The changes are retained to the original data frame.
Syntax : rename(new-col-name = old-col-name)
Arguments
new-col-name: the new column of the data frame
old-col-name: the existing column of the data frame
In the following code snippet, the column rating is renamed by the name feedback_rating.
R
print ( "Renaming rating column" ) data_frame %>% rename (feedback_rating = rating) |
Output
Single-Table Analysis with dplyr using R Language
The dplyr package is used to perform simulations in the data by performing manipulations and transformations. It can be installed into the working space using the following command :
install.packages("dplyr")
Let’s create the main dataframe:
R
#installing the required libraries library (dplyr) #creating a data frame data_frame = data.frame (companies = c ( "Geekster" , "w3wiki" , "Wipro" , "TCS" , "w3wiki" , "w3wiki" , "TCS" , "Wipro" , "Geekster" , "Wipro" ), people = c (100, NA ,532,454,234,554,223,122,432,453), rating = c (4,3,5, NA ,5,3, NA ,4,5,2)) print ( "Original Data frame" ) print (data_frame) |
Output :