fec16 contains data from the Federal Election Commission (FEC) website pertaining to candidates, committees, results, contributions from committees and individuals, and other financial data for the United States 2015-2016 election cycle. Additionally, for the datasets that are included as samples, the package includes functions that import the full versions.
fec16
is hosted on GitHub and call be installed by running the following:
candidates
: candidates registered with the FEC during the 2015-2016 election cyclecommittees
: committees registered with the FEC during the 2015-2016 election cyclecampaigns
: the house/senate current campaignsresults_house
: the house results of the 2016 general presidential electionresults_senate
: the senate results of the 2016 general presidential electionresults_president
: the final results of the 2016 general presidential electionpac
: Political Action Committee (PAC) and party summary financial informationindividuals
: individual contributions to candidates/committees during the 2016 general presidential electioncontributions
: candidates and their contributions from committees during the 2016 general electionexpenditures
: the operating expenditurestransactions
: transactions between committeesThe following functions retrieve the entire datasets for the sampled ones listed above. The size of the raw file that is downloaded by calling each function is given for reference. All functions have an argument n_max
which defaults to the entire dataset but the user can specify the max length of the dataset to be loaded via this argument.
read_all_individuals()
~ 1.45GBread_all_contributions()
~ 15.4MBread_all_expenditures()
~ 52.1MBread_all_transactions()
~ 79.2MBNote: When these functions are run in the console, it is helpful to know the progress of the download taking place but running these functions in a R Markdown document leads to the progress bar of the download being printed repeatedly. A possible solution is to wrap the function in invisible(utils::capture.output())
hereby suppressing the messages.
fec16
can be used to summarize data in order see how many candidates are running for elections (in all offices) for the two major parties:
library(dplyr)
data <- candidates %>%
filter(cand_pty_affiliation %in% c("REP", "DEM")) %>%
group_by(cand_pty_affiliation) %>%
summarize(size = n())
data
#> # A tibble: 2 x 2
#> cand_pty_affiliation size
#> <chr> <int>
#> 1 DEM 1258
#> 2 REP 1481
We can visualize the above data:
library(ggplot2)
ggplot(data, aes(x = cand_pty_affiliation, y = size, fill = cand_pty_affiliation)) +
geom_col() +
labs(
title = "Number of Candidates Affiliated with the Two Major Parties",
x = "Party", y = "Count", fill = "Candidate Party Affiliation"
)