Save up to $499! Grab all Python courses for $49 or all online courses we’ve ever launched for only $169. Only Feb 11-16. Happy Valentine's!
6. Uniting two columns
Changing data format


Oops! We wanted to keep the original column, but we forgot to use remove! What can we do?

One solution is to join two columns using the unite() function. If we wanted to join users' first and last names to make a full name, we'd write:

unite(users, name, first_name, last_name, sep = "_")

The arguments, in the order in which they appear, are the dataset name (users), the new column's name (name), the columns we want to join (first_name and last_name), and the separator used to join them. We've used the underscore character here, but we could have omitted that; R unites using an underscore by default.


Join the users dataset columns email_name and email_domain to form a new column named email. Use the unite() function and @ as the new separator.

Stuck? Here's a hint!


unite(users, email, email_name, email_domain, sep = "@")