Grouping and summarizing Flashcards
(5 cards)
Which function turns many observations into one data point?
summarize()
Ex: my_tibble %>%
summarize(meanLifeExp =
mean(lifeExp))
How can you summarize multiple things at the same time?
Using commas.
Ex: my_tibble %>%
summarize(meanLifeExp =
mean(lifeExp),
medianPop = median(pop))
Which function tells dplyr to summarize within groups rather than summarizing the entire data set?
group_by()
Ex: my_tibble %>%
group_by(year) %>%
summarize(meanLifeExp = mean(lifeExp))
How can you group by multiple things at the same time?
Using commas.
Ex: my_tibble %>%
group_by(year, continent) %>%
summarize(meanLifeExp =
mean(lifeExp),
medianPop = median(pop))
Which function allows you to specify where the x or y axis’ should begin or end?
expand_limits()
Ex: … geom_point() +
expand_limits(y = 0)