-
Notifications
You must be signed in to change notification settings - Fork 19
Description
I recently read with interest your blog post here:
https://freerangestats.info/blog/2024/12/23/depression-and-vote
Really interesting stuff and a great analysis to showcase random effects.
The code did not run at first on my machine, but that was because the command percent was not being executed
draw chart:
combined |>
ggplot(aes(x= cpe, y = per_gop)) +
geom_point(colour = "steelblue", alpha = 0.5) +
geom_smooth(method = "lm", fill = "black", colour = "white", alpha = 0.8) +
scale_x_continuous(label = percent) +
scale_y_continuous(label = percent) +
labs(x = "Crude prevalence estimate of depression",
y = "Percentage vote for Trump in 2024 election",
subtitle = "Line is ordinary least squares fit to all county data together",
title = "Counties with more depression voted more for Trump",
caption = the_caption)
after a quick google search it seems like this might be a safer option, calling it from package scales explicitly
draw chart:
combined |>
ggplot(aes(x= cpe, y = per_gop)) +
geom_point(colour = "steelblue", alpha = 0.5) +
geom_smooth(method = "lm", fill = "black", colour = "white", alpha = 0.8) +
scale_x_continuous(label = scales::percent) +
scale_y_continuous(label = scales::percent) +
labs(x = "Crude prevalence estimate of depression",
y = "Percentage vote for Trump in 2024 election",
subtitle = "Line is ordinary least squares fit to all county data together",
title = "Counties with more depression voted more for Trump",
caption = the_caption)
just a suggestion to improve the material for others.