-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME.Rmd
More file actions
114 lines (75 loc) · 4.17 KB
/
README.Rmd
File metadata and controls
114 lines (75 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# fec20 <img src="data-raw/Sticker/hex_fec20.png" align="right" height=140/>
<!-- badges: start -->
[](https://www.tidyverse.org/lifecycle/#maturing)
[](https://CRAN.R-project.org/package=fec20)
[](https://github.com/baumer-lab/fec20/actions/workflows/R-CMD-check.yml)
<!-- badges: end -->
**fec20** contains data from the [Federal Election Commission (FEC)](https://www.fec.gov/) website pertaining to candidates, committees, results (forthcoming), contributions from committees and individuals, and other financial [data for the United States 2019-2020 election cycle](https://www.fec.gov/data/browse-data/?tab=bulk-data). Additionally, for the datasets that are included as samples, the package includes functions that import the full versions.
This package is a natural successor of the [`fec16` R package](https://github.com/baumer-lab/fec16) (that contains data from the 2015-2016 elections). `fec16` is available on CRAN.
## Installation
Install the development version from GitHub:
```{r, eval = FALSE}
# If you haven't installed the remotes package yet, do so:
# install.packages("remotes")
remotes::install_github("baumer-lab/fec20")
```
```{r message=FALSE, warning=FALSE}
# Load package
library(fec20)
```
## Datasets Included
### Full Datasets
- `candidates`: candidates registered with the FEC during the 2019-2020 election cycle
- `committees`: committees registered with the FEC during the 2019-2020 election cycle
- `campaigns`: the House/Senate current campaigns
- `pac`: Political Action Committee (PAC) and party summary financial information
- `states`: geographical information about the 50 states
### Sample Datasets (with 1000 random rows each)
- `individuals`: individual contributions to candidates/committees during the 2020 election cycle
- `contributions`: candidates and their contributions from committees during the 2020 election cycle
- `expenditures`: the operating expenditures
- `transactions`: transactions between committees
### Forthcoming Datasets
There are 3 forthcoming datasets that contain results from the House, Senate, and Presidential elections.
## Functions Included
The 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()` ~ 9.33GB
- `read_all_contributions()` ~ 28.9MB
- `read_all_expenditures()` ~ 65.6MB
- `read_all_transactions()` ~ 235MB
## How is the data relational?
The headers of each table show the dataset name. The underlined variables are **primary keys** while all the others are **foreign keys**. The arrows show how the datasets are connected.
<img src="inst/fec20-dm.jpeg" align="center"/>
The diagram is built using the `dm` R package. The code can be found in `data-raw/dm.R`.
## Usage and Examples
All the included datasets in `fec20` are lazy-loaded, so you can easily load it via:
```{r, eval=FALSE}
head(candidates)
?candidates
# If using RStudio:
View(candidates)
```
To use any of the `read_all_*` functions, you can run:
```{r, eval=FALSE}
all_contributions <- read_all_expenditures()
```
For example usage of the datasets, please view the [vignette](https://github.com/baumer-lab/fec20/blob/main/vignettes/fec20.Rmd).
## See Also
If you are interested in political data, check out the following related packages:
- [`politicaldata`](https://github.com/elliottmorris/politicaldata/)
- [`ProPublicaR`](https://github.com/dietrichson/ProPublicaR)
## Contributors
- [Marium Tapal](https://github.com/mariumtapal)
- [Benjamin S. Baumer](https://github.com/beanumber)