diff --git a/factors.Rmd b/factors.Rmd index b212d8b..336f135 100644 --- a/factors.Rmd +++ b/factors.Rmd @@ -209,8 +209,8 @@ Another type of reordering is useful when you are colouring the lines on a plot. ```{r, fig.align = "default", out.width = "50%", fig.width = 4} by_age <- gss_cat %>% filter(!is.na(age)) %>% - group_by(age, marital) %>% - count() %>% + count(age, marital) %>% + group_by(age) %>% mutate(prop = n / sum(n)) ggplot(by_age, aes(age, prop, colour = marital)) +