forked from desh2608/gerrymandering
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gerry.R
49 lines (33 loc) · 916 Bytes
/
gerry.R
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
library(rgdal)
library(maptools)
library(ggplot2)
library(broom)
library(rgeos)
## read shapefile
ohio <- readOGR("ohio/precincts_results.shp")
## create adjacency matrix
adj_matrix <- gTouches(ohio, byid=TRUE, returnDense=FALSE)
## Score functions for a redistricting
## This function takes as input a possible
## redistricting, and assigns a score to it
## which is the weighted sum of several
## scores.
## A redistricting E is just a list of vectors,
## where each element in the list represents
## a district, and each element in a vector
## represents a precinct.
# Total score: section 3.1
score.total <- function(E){
}
# Population score: section 3.1.1
score.pop <- function(E){
}
# Isoperimetric score: section 3.1.2
score.isoperimetric <- function(E){
}
# County score: section 3.1.3
score.county <- function(E){
}
# Minority score: section 3.1.4
score.minority <- function(E){
}