Visualizing Ground Support
JOUR 377
Overview 💡
All data I will be using came from the Federal Election Commission. To look into ground support by candidate, we filtered to donations that are between $0-$100 and from 09/01/2022 to 11/15/2022.
Graphic 📈
Code
# returns quartile rank
# Returns quartile rank
quartile_rank <- function(x = 0:99) {
# Set quartile
quart_breaks <- c(
-Inf,
quantile(x,
probs = c(.25, .5, .75),
na.rm = TRUE
),
Inf
)
cut(x = x, breaks = quart_breaks, labels = FALSE)
}
# for warnock
quart_warnock <- warnock %>%
select(committee_name_2, contribution_receipt_amount) %>%
mutate(cont_quart = quartile_rank(contribution_receipt_amount)) %>%
group_by(cont_quart)
# for walker
quart_walker <- walker %>%
select(committee_name_2, contribution_receipt_amount) %>%
mutate(cont_quart = quartile_rank(contribution_receipt_amount)) %>%
group_by(cont_quart)
# combining data
walker_warnock <- merge(quart_walker, quart_warnock)
# barplot
ggplot() +
geom_col(data = quart_warnock, aes(x = committee_name_2,
y = contribution_receipt_amount,
fill = cont_quart)) +
geom_col(data = quart_walker, aes(x = committee_name_2,
y = contribution_receipt_amount,
fill = cont_quart))