Created
April 14, 2019 15:14
-
-
Save aqd14/6ab9a5540ec269852cd7ea3dcaad3517 to your computer and use it in GitHub Desktop.
When we `fill` the plot with `gender`, it implicitly groups the data according to `gender`. Using `interaction` to tell `ggplot` to group data by both variables.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grand_slam_ages %>% | |
mutate(decade = 10 * (year %/% 10)) %>% | |
ggplot(aes(decade, age, fill = gender, group = interaction(decade, gender))) + | |
geom_boxplot() + | |
scale_x_continuous(breaks = seq(1950, 2021, 10)) + | |
expand_limits(x = 2020) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment