redist.group.percent computes the proportion that a group makes up in each district across a matrix of maps.

group_frac(
  map,
  group_pop,
  total_pop = map[[attr(map, "pop_col")]],
  .data = pl()
)

redist.group.percent(plans, group_pop, total_pop, ncores = 1)

Arguments

map

a redist_map object

group_pop

A numeric vector with the population of the group for every precinct.

total_pop

A numeric vector with the population for every precinct.

.data

a redist_plans object or matrix of plans

plans

A matrix with one row for each precinct and one column for each map. Required.

ncores

Number of cores to use for parallel computing. Default is 1.

Value

matrix with percent for each district

Examples

data(fl25)
data(fl25_enum)

cd <- fl25_enum$plans[, fl25_enum$pop_dev <= 0.05]
fl25_map = redist_map(fl25, ndists=3, pop_tol=0.1)
#> Projecting to CRS 3857
fl25_plans = redist_plans(cd, fl25_map, algorithm="enumpart")

group_frac(fl25_map, BlackPop, TotPop, fl25_plans)
#>   [1] 0.15569192 0.25247685 0.10955591 0.19637123 0.21074842 0.10955591
#>   [7] 0.17732012 0.25887112 0.08746585 0.17732012 0.25247685 0.08952607
#>  [13] 0.17266694 0.27654976 0.06984788 0.17266694 0.28437724 0.05692216
#>  [19] 0.16052788 0.24574396 0.10955591 0.16253870 0.28437724 0.07146703
#>  [25] 0.14297175 0.29852009 0.08746585 0.18279646 0.25183036 0.08746585
#>  [31] 0.18279646 0.24574396 0.08952607 0.15478911 0.25561232 0.10955591
#>  [37] 0.15158693 0.25893710 0.10955591 0.15870284 0.24922832 0.10955591
#>  [43] 0.19154617 0.07312233 0.25561232 0.19154617 0.07146703 0.26223776
#>  [49] 0.17591625 0.26223776 0.08746585 0.17591625 0.25561232 0.08952607
#>  [55] 0.06570103 0.26061010 0.19762807 0.06570103 0.25945093 0.19771356
#>  [61] 0.05523813 0.25945093 0.20492044 0.08193173 0.24184865 0.19864849
#>  [67] 0.08193173 0.24101964 0.19875178 0.05247875 0.25887112 0.20492044
#>  [73] 0.12111828 0.28437724 0.10955591 0.05150092 0.25893710 0.20492044
#>  [79] 0.07094517 0.24101964 0.20492044 0.13225866 0.27654976 0.10955591
#>  [85] 0.17176966 0.26223776 0.08952607 0.06767722 0.25016809 0.19762807
#>  [91] 0.06767722 0.24922832 0.19771356 0.15923106 0.25016809 0.10955591
#>  [97] 0.09042369 0.22431205 0.20492044 0.14201996 0.28437724 0.08952607
#> [103] 0.15672274 0.25183036 0.10955591 0.07296264 0.24184865 0.20492044
#> [109] 0.05909645 0.25016809 0.20492044 0.14373979 0.11921812 0.25702238
#> [115] 0.13578053 0.07000805 0.31352220 0.12701667 0.19185622 0.19864849
#> [121] 0.12701667 0.19186280 0.19875178 0.12302202 0.27470243 0.11921812
#> [127] 0.12302202 0.08258869 0.31352220 0.05748505 0.26061010 0.20492044
#> [133] 0.13420752 0.31352220 0.06984788 0.16715800 0.11921812 0.23657909
#> [139] 0.15016739 0.05423124 0.31352220 0.15872904 0.04707140 0.31352220
#> [145] 0.19547663 0.07000805 0.25702238 0.17841255 0.08097525 0.25702238
#> [151] 0.16994859 0.15058844 0.19864849 0.12785821 0.31352220 0.07404886
#> [157] 0.11581273 0.25506736 0.15058844 0.11581273 0.27470243 0.12657980
#> [163] 0.11581273 0.08741876 0.31352220 0.11962673 0.19875178 0.20417381
#> [169] 0.09913088 0.16369828 0.25702238 0.09913088 0.18606496 0.23657909
#> [175] 0.14476308 0.05569711 0.31352220 0.14255453 0.06248724 0.31352220
#> [181] 0.13401679 0.07146703 0.31352220 0.11729986 0.31352220 0.08746585
#> [187] 0.13335542 0.07119078 0.31352220 0.13531896 0.12657980 0.25702238
#> [193] 0.13531896 0.15058844 0.23657909 0.11023472 0.20417381 0.20492044
#> [199] 0.17060391 0.15058844 0.19762807 0.14524591 0.05692216 0.31352220
#> [205] 0.16092157 0.25702238 0.10279716 0.17031597 0.15058844 0.19875178
#> [211] 0.15804717 0.25702238 0.10457394 0.17371723 0.27470243 0.07146703
#> [217] 0.13074827 0.07312233 0.31352220 0.15591287 0.04784772 0.31352220
#> [223] 0.17096600 0.15058844 0.19771356 0.09477141 0.31352220 0.10955591
#> [229] 0.16251851 0.15058844 0.20492044 0.19196614 0.07119078 0.25702238
#> [235] 0.11445147 0.31352220 0.08952607 0.23829433 0.08097525 0.19762807
#> [241] 0.20837790 0.05423124 0.25702238 0.18383193 0.25702238 0.07404886
#> [247] 0.20134065 0.06248724 0.25702238 0.23663392 0.08097525 0.19864849
#> [253] 0.14753875 0.05514963 0.31352220 0.19234674 0.25702238 0.06984788
#> [259] 0.17713306 0.25702238 0.08746585 0.20207411 0.05692216 0.25702238
#> [265] 0.20461687 0.11921812 0.19875178 0.19351658 0.07146703 0.25702238
#> [271] 0.19325296 0.12657980 0.19762807 0.20055867 0.05569711 0.25702238
#> [277] 0.19227698 0.12657980 0.19864849 0.15700596 0.27470243 0.08746585
#> [283] 0.18373370 0.23657909 0.10279716 0.21729357 0.07000805 0.23657909
#> [289] 0.21758790 0.04707140 0.25702238 0.26053128 0.05569711 0.19762807
#> [295] 0.25467976 0.07119078 0.19762807 0.19227683 0.12657980 0.19875178
#> [301] 0.18873848 0.07312233 0.25702238 0.18028046 0.25506736 0.08746585
#> [307] 0.25270009 0.07119078 0.19864849 0.22159646 0.19875178 0.10279716
#> [313] 0.21531673 0.07146703 0.23657909 0.14906358 0.16369828 0.20492044
#> [319] 0.21349242 0.07119078 0.23657909 0.26120764 0.05692216 0.19864849
#> [325] 0.18550147 0.12657980 0.20492044 0.19949178 0.23657909 0.08746585
#> [331] 0.20471681 0.05514963 0.25702238 0.26915139 0.05423124 0.19864849
#> [337] 0.21369565 0.23657909 0.06984788 0.23592011 0.08097525 0.19875178
#> [343] 0.21801351 0.19864849 0.10457394 0.24156999 0.19864849 0.07404886
#> [349] 0.18053285 0.23657909 0.10457394 0.22205007 0.06914946 0.23657909
#> [355] 0.25523216 0.07146703 0.19864849 0.25634739 0.07000805 0.19875178
#> [361] 0.27931225 0.04707140 0.19864849 0.19323696 0.12657980 0.19771356
#> [367] 0.15309332 0.27470243 0.08952607 0.16938502 0.27470243 0.07312233
#> [373] 0.23852168 0.04707140 0.23657909 0.24328778 0.19762807 0.07404886
#> [379] 0.19641184 0.25506736 0.07146703 0.22933119 0.05423124 0.23657909
#> [385] 0.25259455 0.19864849 0.06984788 0.23754266 0.08097525 0.19771356
#> [391] 0.23977081 0.05237970 0.23657909 0.26325811 0.05692216 0.19762807
#> [397] 0.13196768 0.27470243 0.10955591 0.22270792 0.05692216 0.23657909
#> [403] 0.26252537 0.06248724 0.19864849 0.21944189 0.19762807 0.10457394
#> [409] 0.22268083 0.06248724 0.23657909 0.19520915 0.11902088 0.20492044
#> [415] 0.17275828 0.25702238 0.08952607 0.25855956 0.05569711 0.19864849
#> [421] 0.23069417 0.08097525 0.20492044 0.25455617 0.19762807 0.06984788
#> [427] 0.21371638 0.04784772 0.25702238 0.27138019 0.05423124 0.19762807
#> [433] 0.17588836 0.25506736 0.08952607 0.25159583 0.19875178 0.06984788
#> [439] 0.22540525 0.05514963 0.23657909 0.24246314 0.19771356 0.07404886
#> [445] 0.25416526 0.07146703 0.19875178 0.28020469 0.04707140 0.19771356
#> [451] 0.24078481 0.19875178 0.07404886 0.24239569 0.06934862 0.20492044
#> [457] 0.27650032 0.04784772 0.19762807 0.25942975 0.05569711 0.19771356
#> [463] 0.19162861 0.25506736 0.07312233 0.19468019 0.23657909 0.08952607
#> [469] 0.25169155 0.07119078 0.19875178 0.26787511 0.05423124 0.19875178
#> [475] 0.26343771 0.06248724 0.19771356 0.23438854 0.04784772 0.23657909
#> [481] 0.26134832 0.06248724 0.19875178 0.27004651 0.05423124 0.19771356
#> [487] 0.26429338 0.05514963 0.19864849 0.23578904 0.07404886 0.20492044
#> [493] 0.21012874 0.07312233 0.23657909 0.22480552 0.08741876 0.20492044
#> [499] 0.26009105 0.05692216 0.19875178 0.15461732 0.25506736 0.10955591
#> [505] 0.26209089 0.05692216 0.19771356 0.21758387 0.19875178 0.10457394
#> [511] 0.25362190 0.07119078 0.19771356 0.26367891 0.05423124 0.20492044
#> [517] 0.27420711 0.04784772 0.19864849 0.25350900 0.19771356 0.06984788
#> [523] 0.24872847 0.07312233 0.19864849 0.25750552 0.05569711 0.19875178
#> [529] 0.27784995 0.04707140 0.19875178 0.25311968 0.05569711 0.20492044
#> [535] 0.26640526 0.05514963 0.19762807 0.21898133 0.19771356 0.10457394
#> [541] 0.27508968 0.04784772 0.19771356 0.27285574 0.04784772 0.19875178
#> [547] 0.26517837 0.05514963 0.19771356 0.26887391 0.04784772 0.20492044
#> [553] 0.24779646 0.07312233 0.19875178 0.23143590 0.08156994 0.20492044
#> [559] 0.25882623 0.05514963 0.20492044 0.22288230 0.08929802 0.20492044
#> [565] 0.26311935 0.05514963 0.19875178 0.23311308 0.08105612 0.20492044
#> [571] 0.22728449 0.08302913 0.20492044 0.21891136 0.09091400 0.20492044