alarm-redist / redist

Simulation methods for legislative redistricting.
https://alarm-redist.github.io/redist/
GNU General Public License v2.0
67 stars 23 forks source link

prec_assignment gives error "subscript out of bounds" #93

Closed jdjohn215 closed 3 years ago

jdjohn215 commented 3 years ago

I apologize if I'm missing something obvious with this function, but the function prec_assignment appears not to work.

Here is a simple example.

# setup up some data
library(redist)

data(iowa)

iowa_map = redist_map(iowa, existing_plan=cd_2010, pop_tol=0.01, total_pop = pop)

iowa_plans = redist_smc(iowa_map, nsims=10, compactness=1)

prec_assignment(prec = "19001", .data = iowa_plans)

This gives me the error:

Error in get_plans_matrix(.data)[prec, idxs, drop = F] : subscript out of bounds

CoryMcCartan commented 3 years ago

prec should be the row number (of the redist_map object) corresponding to the precinct. I realize the documentation isn't clear on this point, and it would be useful to also be able to provide a human-readable label like a FIPS code or VTD name. We'll work on that for next version.

jdjohn215 commented 3 years ago

Ah! I see. Shoulda figured that out my own. It's a really fantastic package, by the way.