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 Unite() in R
Solution:
Unite() is used to merge two or more variables into one. In some scenarios, we may need to combine the values of two or more variables into one variable and thus Unite() does the same.
We can use the “flights” dataset that we had used before for the Dplyr examples:
Flights |
In the above Dataset, we will use the Unite() function to merge the columns “year”,”month” and “day” into one single column as “date” and below is the code and the output: