Hi,
I want to add another binary variable to "MM_binary" called "CMM_binary" to make two lines on the plot. I can plot points but want to draw lines between them, adding geom_path() after geom_point() + comes up with an error.
alt_summary <- trimmed_df %>%
group_by(CarsQuintile_group, MM_binary) %>%
summarise(n = n()) %>% pivot_wider(id_cols="CarsQuintile_group",
names_from="MM_binary",
values_from="n") %>%
mutate(frac=1
/(1
+0
),
labels=scales::percent(frac))
alt_summary
alt_summary %>%
ggplot(aes(x = CarsQuitile_group, y = frac)) +
geom_point() +
scale_y_continuous(limits = c(0, 1),
breaks = scales::pretty_breaks(),
labels = scales::percent_format(scale = 100)) +
theme(legend.position = "top") +
labs(title = "Prevalence of MM_binary",
y = "% of population",
x = "SIMD", color = "grey20", size = 20, angle = 90) -> figure_1
figure_1
Any ideas?
Thanks