redist icon indicating copy to clipboard operation
redist copied to clipboard

`chain` entry in `redist_plans` gets overwritten in `rbind()`

Open christopherkenny opened this issue 11 months ago • 0 comments

Reprex as requested @CoryMcCartan

devtools::load_all()
#> ℹ Loading redist
#> Loading required package: redistmetrics

data(iowa)
ia <- redist_map(iowa, existing_plan = cd_2010, pop_tol = 0.01)
plans_1 <- redist_smc(ia, 100, runs = 2)
plans_2 <- redist_smc(ia, 100, runs = 2)

rbind(plans_1, plans_2) |> 
    dplyr::count(chain)
#>   chain   n
#> 1     1 804
#> 2     2 804

Created on 2024-03-20 with reprex v2.0.2

Instead, this should look something like NA, 1, 2, NA, 3, 4 but it comes out as 1, 2 because of this line: https://github.com/alarm-redist/redist/blob/d2e4836869355e58d5d20db154feb121a6d76632/R/redist_plans.R#L509

christopherkenny avatar Mar 20 '24 20:03 christopherkenny