The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Common Arguments to redist Functions

library(redist)
data(iowa)
iowa_map <- redist_map(iowa, existing_plan = cd_2010, total_pop = pop)

adj

# Standard eval - 
adj <- redist.adjacency(shp = iowa)
# tidy eval - 
adj <- get_adj(iowa_map)

head(adj)
#> [[1]]
#> [1]  1 14 38 60 87
#> 
#> [[2]]
#> [1]  0 14 68 86 87
#> 
#> [[3]]
#> [1] 21 95
#> 
#> [[4]]
#> [1] 25 67 92
#> 
#> [[5]]
#> [1] 13 14 38 82
#> 
#> [[6]]
#> [1]  6  9 47 56 85
# Plot it!
redist.plot.adj(shp = iowa_map)

ndists

# Standard eval - 
ndists <- 4
# tidy eval - stored within redist_map object
attr(iowa_map, 'ndists')
#> [1] 4

nsims

nsims <- 100

pop_tol

# standard eval - 
pop_tol <- 0.01

# tidy eval - stored within redist_map object
# - getting
get_pop_tol(iowa_map)
#> [1] 5.350657e-05
# - setting
iowa_map <- set_pop_tol(iowa_map, pop_tol = 0.01)

plan

sim <- redist.rsg(adj = adj, total_pop = iowa$pop, ndists = 4, pop_tol = 0.01)
#> 
#> ==================== 
#> redist.rsg(): Automated Redistricting Starts
#> 
#> 
#>  4 districts built using 99 precincts in 0.04 seconds...

head(sim$plan)
#> [1] 1 3 2 4 1 1

plans

sims <- redist_smc(map = iowa_map, nsims = 10, silent = TRUE)
plans <- get_plans_matrix(sims)

init_plan

# standard eval - 
init_plan <- iowa$cd_2010

# tidy eval - stored within redist_map object
get_existing(iowa_map)
#>  [1] 3 3 1 2 4 1 1 4 1 1 4 4 4 4 3 2 4 4 4 2 4 1 2 4 3 2 2 1 2 4 1 4 1 4 4 3 4 4
#> [39] 3 4 4 4 4 2 1 4 4 1 1 2 2 2 1 2 4 2 1 2 2 4 3 2 2 1 3 1 4 2 3 2 4 4 3 4 4 4
#> [77] 3 3 1 3 4 2 4 4 4 1 3 3 2 2 3 2 2 4 4 1 4 1 4

total_pop

# standard eval
total_pop <- iowa$pop

# tidy eval - a column within the redist_map object tracked by attributes
iowa_map[[attr(iowa_map, 'pop_col')]]
#>  [1]   7682   4029  14330  12887   6119  26076 131090  26306  24276  20958
#> [11]  20260  14867   9670  20816  13956  18499  44151  12072  12439   9286
#> [21]  16667  18129  49116  17096  66135   8753   8457  17764  40325  16667
#> [31]  93653  10302  20880  16303  10680   7441   9336  12453  10954  15673
#> [41]  11341  17534  14928  20145   9566   9815   7089  16355  19848  36842
#> [51]  16843 130882  20638  10511  15543  35862 211226  11387   8898  11581
#> [61]  15679  22381  33309  40648  15059  10776   9243   7970  10740  42745
#> [71]  14398   6462  15932   9421  24986   7310 430640  93158  18914   5131
#> [81]  10350 165224  12167  33704  89542  17767   6317  12534   7570  35625
#> [91]  46225  21704   6403  38013  10866  21056 102172   7598  13229

group_pop

iowa$white
#>  [1]   7507   3922  13325  12470   6007  25387 109968  25194  23459  20344
#> [11]  13756  14552   9470  20119  13502  17897  40876  11553  12048   8208
#> [21]  15843  17563  45454  12541  58630   8556   7946  17408  36059  16255
#> [31]  86981   9319  19987  15443   9334   7123   9017  12190  10595  14344
#> [41]  10744  16430  14532  18141   9314   9288   6907  15818  19223  35284
#> [51]  14539 108767  19716  10286  15121  32833 188592   9309   8720  11267
#> [61]  15233  21242  31834  31807  14390  10564   8904   7677  10265  34518
#> [71]  13605   5937  14767   9108  23782   7043 347710  83609  17705   4966
#> [81]  10031 136884  11763  30090  77812  14874   5872  12029   7373  31157
#> [91]  44266  20114   6244  34210  10247  20153  79282   7335  11738

pop_bounds

# tidy eval - stored in redist_map object
attr(iowa_map, 'pop_bounds')
#> [1] 753972.9 761588.8 769204.6

ncores

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.