May 2019
Beginner to intermediate
266 pages
5h 57m
English
The summarize() function is used to aggregate multiple column values to a single column. It is predominantly used with the group_by() function.
Consider a scenario in which we want to summarize the data as per the displacement covered by the automobiles. In this case, the following command can be executed with a combination of the group_by() and summarize() functions:
> mpgSummarize<- mpg %>% group_by(displ) %>% summarize(avg_displ=mean(displ))> mpgSummarize# A tibble: 35 x 2 displ avg_displ <dbl> <dbl> 1 1.6 1.6 2 1.8 1.8 3 1.9 1.9 4 2 2 5 2.2 2.2 6 2.4 2.4 7 2.5 2.5 8 2.7 2.7 9 2.8 2.810 3 3 # ... with 25 more rows > View(mpgSummarize)
The following table gives summarized details relating to displacement and the ...
Read now
Unlock full access