This demo is to accompany this blog post.
people <- read.csv("https://raw.githubusercontent.com/summerofgeorge/training-assets/master/baseball/people.csv") library(dplyr) people %>% select(height)
# What do you anticipate when you
# run this code?
people %>%
group_by(birthCountry) %>%
summarise(avg_height = mean(height)) %>%
order_by(avg_height)
# Now run it.
# Did it do what you thought?
# Debug this code to run.
people %>%
group_by(birthCountry) %>%
summarise(avg_height = mean(height)) %>%
arrange(avg_height)
Are all your `dplyr` verbs right? Check the documentation to make sure: https://www.rdocumentation.org/packages/dplyr/versions/0.7.8.
people <- read.csv("https://raw.githubusercontent.com/summerofgeorge/training-assets/master/baseball/people.csv") library(dplyr) people %>% select(height)
# Now, modify this code
# to find the minimum height by country.
# Include only players born after 1985.
people %>%
group_by(birthCountry) %>%
summarise(avg_height = mean(height)) %>%
arrange(avg_height)
people %>%
filter(birthYear > 1985) %>%
group_by(birthCountry) %>%
summarise(min_height = min(height)) %>%
arrange(min_height)
Are all your `dplyr` verbs right? Check the documentation to make sure: https://www.rdocumentation.org/packages/dplyr/versions/0.7.8.
Leave a Reply