Herein, we will utilize the split() and unsplit() functions to separate and recreate datasets, and then use filter() from dplyr to supplement knowledge of how to split data.
In order to do so, the following steps have to be executed:
- Load the iris dataset if it is not currently loaded using the following code:
data(iris)
- Split the iris dataset by species. This creates three lists of dataframes, each of which will only contain the information about one species of iris represented in the data. Verify that iris_species is a list by checking its type and check the class of iris_species[[1]]. This can be done with the help of the following code:
iris_species <- split(iris, iris$Species)