From the course: Data Wrangling in R
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Combining columns with unite()
From the course: Data Wrangling in R
Combining columns with unite()
- [Instructor] In some data wrangling operations, we need to combine multiple columns into a single column. The unite function from the Tidyverse allows you to create a single column by combining the contents of two or more existing columns. Let's take a look at the syntax for this function. You call the unite function after loading the Tidyverse and give it up to four arguments. First, you provide the name of the tibble or data frame containing your data. Second, you provide the name of the column that you want to create. And then third, you provide the names of the columns that you want to combine into that new column. And then finally, you can optionally provide a separator that you would like R to place between the values and the new column. If you don't specify a separator, R will separate the values with underscores. So let's take a look at how we do this in R. We're going to begin by loading the Tidyverse and the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.