-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME.Rmd
85 lines (62 loc) · 2.67 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
---
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%"
)
```
# geomander <a href='https://christophertkenny.com/geomander/'><img src='man/figures/logo.png' align="right" height="137" /></a>
<!-- badges: start -->
[](https://github.com/christopherkenny/geomander/actions)
[](https://CRAN.R-project.org/package=geomander)

[](https://christopherkenny.r-universe.dev/geomander)
<!-- badges: end -->
Focuses on creating data sets and other tools that help make understanding gerrymandering faster and easier. Designed for easy preparation to run simulation analysis with the R package redist, but is aimed at the geographic aspects of redistricting, not partitioning methods. Most of these tools are gathered from seminar papers and do not correspond to a single publication.
## Installation
You can install the released version of geomander from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("geomander")
```
And the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("christopherkenny/geomander")
```
## Examples
A very common task is aggregating block data to precincts.
```{r example, results = 'hide'}
library(geomander)
library(tidyverse)
# load precincts
data('va18sub')
# create block data
block <- create_block_table(state = 'VA', county = '087')
# match the geographies
matches <- geo_match(from = block, to = va18sub)
# Aggregate
prec <- block2prec(block_table = block, matches = matches)
```
Other important tasks include breaking data into pieces by blocks underlying them.
```{r, message=FALSE, warning=FALSE}
library(geomander)
library(tidyverse)
# load precincts
data("va18sub")
# subset to target area
va18sub <- va18sub |> filter(COUNTYFP == '087')
```
Then we can get common block data:
```{r, results='hide', message=FALSE, warning=FALSE}
block <- create_block_table(state = 'VA', county = '087')
```
And estimate down to blocks
```{r}
disagg <- geo_estimate_down(from = va18sub, to = block, wts = block$vap, value = va18sub$G18USSRSTE)
```
For more information, see the documentation and vignettes, available at [https://christophertkenny.com/geomander/](https://christophertkenny.com/geomander/)