Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Changing column data types
Basic data cleaning
7. Change a column name


Our new columns' names do not match the others in the data set. It's best to use consistent column names, so we will change the new names a bit. Let's start by changing EmailName to email_name. We will use the colnames() function. This function returns a vector of names of columns in a data frame, have a look:

colnames(survey)[5] <- c("email_name")

The colnames() function takes a data set as its argument. We use the square brackets notation to access the 5th element (the EmailName column). Finally, we assign it a vector with the new column name.


Change the name of the column FirstName (position 1) to first_name. The data set is survey.