library(remotes)
## Warning: package 'remotes' was built under R version 4.5.1
remotes::install_github("baumer-lab/fec16")
## Skipping install of 'fec16' from a github remote, the SHA1 (19a214d5) has not changed since last install.
## Use `force = TRUE` to force installation
library(fec16)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
joined_df <- results_house %>%
inner_join(campaigns, by = c("cand_id" = "cand_id"))
joined_df <- joined_df %>%
mutate(candidate_party = case_when(
party == "DEM" ~ "Democrat",
party == "REP" ~ "Republican",
TRUE ~ "Other Party"
))
ggplot(joined_df, aes(x = ttl_disb, y = general_votes, color = candidate_party)) +
geom_point(alpha = 0.7) +
labs(
title = "House Race: Votes vs. Campaign Spending",
x = "Total Disbursements ($)",
y = "General Election Votes",
color = "Candidate Party"
) +
theme_minimal() +
theme(
plot.title = element_text(hjust = 0.5)
)
## Warning: Removed 462 rows containing missing values or values outside the scale range
## (`geom_point()`).
