Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Changing column data types
Basic data cleaning
9. Combine multiple columns into one
Summary

Instruction

Suppose we want to do the opposite – join two columns together. We can just use the unite() function, also from the tidyr package. It looks like this:

survey <- unite(
  survey,
  col="email",
  sep="@",
  email_name,
  email_domain)

The arguments are the data set name, the new column name (col), the separating character (sep), and the names of the columns we want to join.

Exercise

Combine the survey's first_name and last_name columns into a new column called name. Use the unite() function. Set an underscore (_) as the sep argument. Assign the result to the united_names variable.