Tidyr:: Separate() in R

Tidyr package is used to create tidy data. Tidy data is a standard way of storing data that is used to ensure that we spend less time fighting with the tools and more time working on the analysis. The different functions of Tidyr package are described here.

Problem:

Use of Tidyr Separate() in R
Solution:
Separate() is used to split a single variable into two or more variables. In some scenarios, a single column captures multiple variables and we may need to separate the values into 2 or more variables or we may need to exclude the unnecessary part of the variable and Separate() does the same.
We can use the “flight_unite” dataset that we had created before in the Tidyr::Unite example:
flight_unite
Below is the code and output to Separate the date column into “month”, “day” and “year” as before:

flight_separate
0

Leave a Reply

Your email address will not be published. Required fields are marked *