forked from MEDSL/elections
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
91 lines (68 loc) · 1.87 KB
/
README.Rmd
File metadata and controls
91 lines (68 loc) · 1.87 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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
devtools::load_all()
library(dplyr)
```
# elections: MEDSL data in R
This is an R package for accessing data on U.S. elections from the [MIT Election Data and Science Lab](https://electionlab.mit.edu).
## Installation
Install from GitHub:
```{r, eval = FALSE}
if (!require('devtools', quietly = TRUE)) install.packages('devtools')
devtools::install_github('MEDSL/elections')
```
## Use
```{r, result = 'hide', message = FALSE, eval = FALSE}
library(elections)
# We'll use dplyr for ease of illustration below
library(dplyr)
```
The package makes available the following datasets:
* [`presidential_precincts_2016`](http://dx.doi.org/10.7910/DVN/LYWX3D)
* [`senate_precincts_2016`](http://dx.doi.org/10.7910/DVN/NLTQAD)
* [`house_precincts_2016`](http://dx.doi.org/10.7910/DVN/PSKDUJ)
* [`state_precincts_2016`](http://dx.doi.org/10.7910/DVN/GSZG1O)
* [`local_precincts_2016`](http://dx.doi.org/10.7910/DVN/Q8OHRS)
* `state_ids`
* `county_ids`
* `county_sub_ids`
```{r}
presidential_precincts_2016 %>%
select(state_postal, county_fips, precinct, candidate, party, votes)
```
```{r}
senate_precincts_2016 %>%
select(state_postal, county_fips, precinct, candidate, party, votes)
```
```{r}
house_precincts_2016 %>%
select(state_postal, county_fips, precinct, candidate, party, votes)
```
```{r}
state_precincts_2016 %>%
select(state_postal, county_fips, precinct, candidate, party, votes)
```
```{r}
local_precincts_2016 %>%
select(state_postal, county_fips, precinct, candidate, party, votes)
```
State identifiers:
```{r}
head(state_ids)
```
County identifiers:
```{r}
head(county_ids)
```
County subdivision identifiers:
```{r}
head(county_sub_ids)
```