From the course: Data Wrangling in R
Unlock this course with a free trial
Join today to access over 25,600 courses taught by industry experts.
Breaking apart columns with separate()
From the course: Data Wrangling in R
Breaking apart columns with separate()
- [Instructor] Putting multiple variables in a single column violates one of the core rules of tidy data. When performing data wrangling, we often need to break those columns apart in this separate variables. The separate function from the tidyverse allows you to break a column into two or more parts. Let's take a look at how the separate function works. You call the separate function after loading the tidyverse and you give it at least four arguments. First, you provide the name of the tibble or data frame containing the column you wish to split. Second, you provide the name of the column from that tibble you want to split. Third, you provide the names of the columns that you want to store the separated data in. And finally, you can optionally provide details on the way you want R to separate the data. This can either be by providing the character or characters that delimit your fields, or by providing the numeric…
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.