Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Changing column data types
Basic data cleaning
6. How to separate columns in two
Summary

## Instruction

Nice job! Now we have all the columns in a workable format. It's time to look at some of them a bit closer.

As you can see, we have first names and last names combined into one column. We need to separate them. We can do this using the separate() function.

If we wanted to do the same with our email addresses, we'd use separate() from the tidyr package, like this:

survey <- separate(
survey,
col="email",
sep="@",
into=c("EmailName", "EmailDomain"))


The arguments are the data set (survey), the column we want to separate (passed as the col argument), the separator we want to use (passed as the sep argument), and the vector of new columns' names. By default, the separate() function removes the old column and adds new ones.

## Exercise

Import the tidyr package. Separate the name column into two new columns: FirstName and LastName. Use the separate() function and reassign the result to the survey variable.

Note: Use '_' as the separator.

### Stuck? Here's a hint!

To import the tidyr package, simply type:

library(tidyr)