November 2016
Beginner to intermediate
959 pages
43h 46m
English
When we have categorical variables, we often want to create groups corresponding to each level and to analyze each group separately to reveal some significant similarities and differences between groups.
The split function divides data into groups based on a factor or vector. The unsplit() function reverses the effect of split.
Download the files for this chapter and store the auto-mpg.csv file in your R working directory. Read the file using the read.csv command and save in the auto variable:
> auto <- read.csv("auto-mpg.csv", stringsAsFactors=FALSE)Split cylinders using the following command:
> carslist <- split(auto, auto$cylinders)
The
split(auto, auto$cylinders) function returns a ...
Read now
Unlock full access