redist
redist copied to clipboard
`match_numbers()` returns ordered factor rather than integer
This breaks left_join
, rbind
, add_reference
to name a few.
library(redist)
#> Warning: package 'redist' was built under R version 4.2.1
#> Loading required package: redistmetrics
#>
#> Attaching package: 'redist'
#> The following object is masked from 'package:stats':
#>
#> filter
data(iowa)
ia <- redist_map(iowa, existing_plan = cd_2010, pop_tol = 0.01)
pl <- redist_smc(ia, nsims = 100)
#> SEQUENTIAL MONTE CARLO
#> Sampling 100 99-unit maps with 4 districts and population between 753973 and 769205.
#> Split [0/3] ■ | ETA?
#> Split [3/3] ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■ | ETA 0s
pl <- match_numbers(pl, ia$cd_2010)
class(pl$district)
#> [1] "ordered" "factor"
Created on 2022-07-25 by the reprex package (v2.0.1)
Preferred approach to resolve: add handlers to add_reference
& rbind.redist_plans
. Use of left_join()
is extremely rare outside 50-states (and even there we can / should just use bind_cols()
)