-
Notifications
You must be signed in to change notification settings - Fork 6
/
README.Rmd
105 lines (82 loc) · 2.11 KB
/
README.Rmd
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
---
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-",
cache.lazy = FALSE
)
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}
data(presidential_precincts_2016)
presidential_precincts_2016 %>%
select(state, county_fips, precinct, candidate, office, votes) %>%
head()
```
```{r}
data(senate_precincts_2016)
senate_precincts_2016 %>%
select(state, county_fips, precinct, candidate, office, votes) %>%
head()
```
```{r}
data(house_precincts_2016)
house_precincts_2016 %>%
select(state, county_fips, precinct, candidate, office, votes) %>%
head()
```
```{r}
data(state_precincts_2016)
state_precincts_2016 %>%
select(state, county_fips, precinct, candidate, office, votes) %>%
head()
```
```{r}
data(local_precincts_2016)
local_precincts_2016 %>%
select(state, county_fips, precinct, candidate, office, votes) %>%
head()
```
State identifiers:
```{r}
data(state_ids)
head(state_ids)
```
County identifiers:
```{r}
data(county_ids)
head(county_ids)
```
County subdivision identifiers:
```{r}
data(county_sub_ids)
head(county_sub_ids)
```