September 2017
Beginner to intermediate
560 pages
25h 18m
English
The split(auto, auto$cylinders) function returns a list of data frames, where each data frame belongs to particulars levels of cylinders variable. To reference a data frame from the list, use the [ notation. Here, carslist[1] is a list of length 1 consisting of the first data frame that corresponds to three cylinder cars, and carslist[[1]] is the associated data frame for the three cylinder cars:
> str(carslist[1]) List of 1 $ 3:'data.frame': 4 obs. of 9 variables: ..$ No : int [1:4] 2 199 251 365 ..$ mpg : num [1:4] 19 18 23.7 21.5 ..$ cylinders : int [1:4] 3 3 3 3 ..$ displacement: num [1:4] 70 70 70 80 ..$ horsepower : int [1:4] 97 90 100 110 ..$ weight : int [1:4] 2330 2124 2420 2720 ..$ acceleration: num [1:4] ...
Read now
Unlock full access