From 02502a6ebc506e050bcb93c489775f045ca3f694 Mon Sep 17 00:00:00 2001 From: Matt Herman Date: Wed, 20 Jun 2018 05:00:59 -0400 Subject: [PATCH] Update factors.Rmd (#624) --- factors.Rmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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)) +