redist.group.percent computes the percentage 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 = cur_plans()
)

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

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] redist.group.percent(plans = cd, group_pop = fl25$BlackPop, total_pop = fl25$TotPop)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] #> [1,] 0.1556919 0.1963712 0.17732012 0.17732012 0.17266694 0.17266694 0.1605279 #> [2,] 0.2524768 0.2107484 0.25887112 0.25247685 0.27654976 0.28437724 0.2457440 #> [3,] 0.1095559 0.1095559 0.08746585 0.08952607 0.06984788 0.05692216 0.1095559 #> [,8] [,9] [,10] [,11] [,12] [,13] [,14] #> [1,] 0.16253870 0.14297175 0.18279646 0.18279646 0.1547891 0.1515869 0.1587028 #> [2,] 0.28437724 0.29852009 0.25183036 0.24574396 0.2556123 0.2589371 0.2492283 #> [3,] 0.07146703 0.08746585 0.08746585 0.08952607 0.1095559 0.1095559 0.1095559 #> [,15] [,16] [,17] [,18] [,19] [,20] #> [1,] 0.19154617 0.19154617 0.17591625 0.17591625 0.06570103 0.06570103 #> [2,] 0.07312233 0.07146703 0.26223776 0.25561232 0.26061010 0.25945093 #> [3,] 0.25561232 0.26223776 0.08746585 0.08952607 0.19762807 0.19771356 #> [,21] [,22] [,23] [,24] [,25] [,26] #> [1,] 0.05523813 0.08193173 0.08193173 0.05247875 0.1211183 0.05150092 #> [2,] 0.25945093 0.24184865 0.24101964 0.25887112 0.2843772 0.25893710 #> [3,] 0.20492044 0.19864849 0.19875178 0.20492044 0.1095559 0.20492044 #> [,27] [,28] [,29] [,30] [,31] [,32] [,33] #> [1,] 0.07094517 0.1322587 0.17176966 0.06767722 0.06767722 0.1592311 0.09042369 #> [2,] 0.24101964 0.2765498 0.26223776 0.25016809 0.24922832 0.2501681 0.22431205 #> [3,] 0.20492044 0.1095559 0.08952607 0.19762807 0.19771356 0.1095559 0.20492044 #> [,34] [,35] [,36] [,37] [,38] [,39] [,40] #> [1,] 0.14201996 0.1567227 0.07296264 0.05909645 0.1437398 0.13578053 0.1270167 #> [2,] 0.28437724 0.2518304 0.24184865 0.25016809 0.1192181 0.07000805 0.1918562 #> [3,] 0.08952607 0.1095559 0.20492044 0.20492044 0.2570224 0.31352220 0.1986485 #> [,41] [,42] [,43] [,44] [,45] [,46] [,47] #> [1,] 0.1270167 0.1230220 0.12302202 0.05748505 0.13420752 0.1671580 0.15016739 #> [2,] 0.1918628 0.2747024 0.08258869 0.26061010 0.31352220 0.1192181 0.05423124 #> [3,] 0.1987518 0.1192181 0.31352220 0.20492044 0.06984788 0.2365791 0.31352220 #> [,48] [,49] [,50] [,51] [,52] [,53] [,54] #> [1,] 0.1587290 0.19547663 0.17841255 0.1699486 0.12785821 0.1158127 0.1158127 #> [2,] 0.0470714 0.07000805 0.08097525 0.1505884 0.31352220 0.2550674 0.2747024 #> [3,] 0.3135222 0.25702238 0.25702238 0.1986485 0.07404886 0.1505884 0.1265798 #> [,55] [,56] [,57] [,58] [,59] [,60] #> [1,] 0.11581273 0.1196267 0.09913088 0.09913088 0.14476308 0.14255453 #> [2,] 0.08741876 0.1987518 0.16369828 0.18606496 0.05569711 0.06248724 #> [3,] 0.31352220 0.2041738 0.25702238 0.23657909 0.31352220 0.31352220 #> [,61] [,62] [,63] [,64] [,65] [,66] [,67] #> [1,] 0.13401679 0.11729986 0.13335542 0.1353190 0.1353190 0.1102347 0.1706039 #> [2,] 0.07146703 0.31352220 0.07119078 0.1265798 0.1505884 0.2041738 0.1505884 #> [3,] 0.31352220 0.08746585 0.31352220 0.2570224 0.2365791 0.2049204 0.1976281 #> [,68] [,69] [,70] [,71] [,72] [,73] [,74] #> [1,] 0.14524591 0.1609216 0.1703160 0.1580472 0.17371723 0.13074827 0.15591287 #> [2,] 0.05692216 0.2570224 0.1505884 0.2570224 0.27470243 0.07312233 0.04784772 #> [3,] 0.31352220 0.1027972 0.1987518 0.1045739 0.07146703 0.31352220 0.31352220 #> [,75] [,76] [,77] [,78] [,79] [,80] [,81] #> [1,] 0.1709660 0.09477141 0.1625185 0.19196614 0.11445147 0.23829433 0.20837790 #> [2,] 0.1505884 0.31352220 0.1505884 0.07119078 0.31352220 0.08097525 0.05423124 #> [3,] 0.1977136 0.10955591 0.2049204 0.25702238 0.08952607 0.19762807 0.25702238 #> [,82] [,83] [,84] [,85] [,86] [,87] #> [1,] 0.18383193 0.20134065 0.23663392 0.14753875 0.19234674 0.17713306 #> [2,] 0.25702238 0.06248724 0.08097525 0.05514963 0.25702238 0.25702238 #> [3,] 0.07404886 0.25702238 0.19864849 0.31352220 0.06984788 0.08746585 #> [,88] [,89] [,90] [,91] [,92] [,93] [,94] #> [1,] 0.20207411 0.2046169 0.19351658 0.1932530 0.20055867 0.1922770 0.15700596 #> [2,] 0.05692216 0.1192181 0.07146703 0.1265798 0.05569711 0.1265798 0.27470243 #> [3,] 0.25702238 0.1987518 0.25702238 0.1976281 0.25702238 0.1986485 0.08746585 #> [,95] [,96] [,97] [,98] [,99] [,100] [,101] #> [1,] 0.1837337 0.21729357 0.2175879 0.26053128 0.25467976 0.1922768 0.18873848 #> [2,] 0.2365791 0.07000805 0.0470714 0.05569711 0.07119078 0.1265798 0.07312233 #> [3,] 0.1027972 0.23657909 0.2570224 0.19762807 0.19762807 0.1987518 0.25702238 #> [,102] [,103] [,104] [,105] [,106] [,107] [,108] #> [1,] 0.18028046 0.25270009 0.2215965 0.21531673 0.1490636 0.21349242 0.26120764 #> [2,] 0.25506736 0.07119078 0.1987518 0.07146703 0.1636983 0.07119078 0.05692216 #> [3,] 0.08746585 0.19864849 0.1027972 0.23657909 0.2049204 0.23657909 0.19864849 #> [,109] [,110] [,111] [,112] [,113] [,114] [,115] #> [1,] 0.1855015 0.19949178 0.20471681 0.26915139 0.21369565 0.23592011 0.2180135 #> [2,] 0.1265798 0.23657909 0.05514963 0.05423124 0.23657909 0.08097525 0.1986485 #> [3,] 0.2049204 0.08746585 0.25702238 0.19864849 0.06984788 0.19875178 0.1045739 #> [,116] [,117] [,118] [,119] [,120] [,121] [,122] #> [1,] 0.24156999 0.1805329 0.22205007 0.25523216 0.25634739 0.2793123 0.1932370 #> [2,] 0.19864849 0.2365791 0.06914946 0.07146703 0.07000805 0.0470714 0.1265798 #> [3,] 0.07404886 0.1045739 0.23657909 0.19864849 0.19875178 0.1986485 0.1977136 #> [,123] [,124] [,125] [,126] [,127] [,128] #> [1,] 0.15309332 0.16938502 0.2385217 0.24328778 0.19641184 0.22933119 #> [2,] 0.27470243 0.27470243 0.0470714 0.19762807 0.25506736 0.05423124 #> [3,] 0.08952607 0.07312233 0.2365791 0.07404886 0.07146703 0.23657909 #> [,129] [,130] [,131] [,132] [,133] [,134] [,135] #> [1,] 0.25259455 0.23754266 0.2397708 0.26325811 0.1319677 0.22270792 0.26252537 #> [2,] 0.19864849 0.08097525 0.0523797 0.05692216 0.2747024 0.05692216 0.06248724 #> [3,] 0.06984788 0.19771356 0.2365791 0.19762807 0.1095559 0.23657909 0.19864849 #> [,136] [,137] [,138] [,139] [,140] [,141] [,142] #> [1,] 0.2194419 0.22268083 0.1952092 0.17275828 0.25855956 0.23069417 0.25455617 #> [2,] 0.1976281 0.06248724 0.1190209 0.25702238 0.05569711 0.08097525 0.19762807 #> [3,] 0.1045739 0.23657909 0.2049204 0.08952607 0.19864849 0.20492044 0.06984788 #> [,143] [,144] [,145] [,146] [,147] [,148] #> [1,] 0.21371638 0.27138019 0.17588836 0.25159583 0.22540525 0.24246314 #> [2,] 0.04784772 0.05423124 0.25506736 0.19875178 0.05514963 0.19771356 #> [3,] 0.25702238 0.19762807 0.08952607 0.06984788 0.23657909 0.07404886 #> [,149] [,150] [,151] [,152] [,153] [,154] #> [1,] 0.25416526 0.2802047 0.24078481 0.24239569 0.27650032 0.25942975 #> [2,] 0.07146703 0.0470714 0.19875178 0.06934862 0.04784772 0.05569711 #> [3,] 0.19875178 0.1977136 0.07404886 0.20492044 0.19762807 0.19771356 #> [,155] [,156] [,157] [,158] [,159] [,160] #> [1,] 0.19162861 0.19468019 0.25169155 0.26787511 0.26343771 0.23438854 #> [2,] 0.25506736 0.23657909 0.07119078 0.05423124 0.06248724 0.04784772 #> [3,] 0.07312233 0.08952607 0.19875178 0.19875178 0.19771356 0.23657909 #> [,161] [,162] [,163] [,164] [,165] [,166] #> [1,] 0.26134832 0.27004651 0.26429338 0.23578904 0.21012874 0.22480552 #> [2,] 0.06248724 0.05423124 0.05514963 0.07404886 0.07312233 0.08741876 #> [3,] 0.19875178 0.19771356 0.19864849 0.20492044 0.23657909 0.20492044 #> [,167] [,168] [,169] [,170] [,171] [,172] [,173] #> [1,] 0.26009105 0.1546173 0.26209089 0.2175839 0.25362190 0.26367891 0.27420711 #> [2,] 0.05692216 0.2550674 0.05692216 0.1987518 0.07119078 0.05423124 0.04784772 #> [3,] 0.19875178 0.1095559 0.19771356 0.1045739 0.19771356 0.20492044 0.19864849 #> [,174] [,175] [,176] [,177] [,178] [,179] [,180] #> [1,] 0.25350900 0.24872847 0.25750552 0.2778499 0.25311968 0.26640526 0.2189813 #> [2,] 0.19771356 0.07312233 0.05569711 0.0470714 0.05569711 0.05514963 0.1977136 #> [3,] 0.06984788 0.19864849 0.19875178 0.1987518 0.20492044 0.19762807 0.1045739 #> [,181] [,182] [,183] [,184] [,185] [,186] #> [1,] 0.27508968 0.27285574 0.26517837 0.26887391 0.24779646 0.23143590 #> [2,] 0.04784772 0.04784772 0.05514963 0.04784772 0.07312233 0.08156994 #> [3,] 0.19771356 0.19875178 0.19771356 0.20492044 0.19875178 0.20492044 #> [,187] [,188] [,189] [,190] [,191] [,192] #> [1,] 0.25882623 0.22288230 0.26311935 0.23311308 0.22728449 0.2189114 #> [2,] 0.05514963 0.08929802 0.05514963 0.08105612 0.08302913 0.0909140 #> [3,] 0.20492044 0.20492044 0.19875178 0.20492044 0.20492044 0.2049204