Aggregates block table values up to a higher level, normally precincts, hence the name block2prec.

block2prec(block_table, matches, geometry = FALSE)

Arguments

block_table

Required. Block table output from create_block_table

matches

Required. Grouping variable to aggregate up by, typically made with geo_match

geometry

Boolean. Whether to keep geometry or not.

Value

dataframe with length(unique(matches)) rows

Examples

set.seed(1)
data(rockland)
rockland$id <- sample(c(1:2, 4), nrow(rockland), TRUE)
block2prec(rockland, rockland$id)
#> # A tibble: 4 × 24
#>   matches_id waterpct    pop pop_white pop_black pop_hisp pop_aian pop_asian
#>        <dbl>    <dbl>  <dbl>     <dbl>     <dbl>    <dbl>    <dbl>     <dbl>
#> 1          1     40.1 108145     71422     12109    16272      170      6486
#> 2          2     48.3 103132     68520     10470    16357      140      5939
#> 3          3      0        0         0         0        0        0         0
#> 4          4     37.7 100410     63728     12044    16154      177      6674
#> # ℹ 16 more variables: pop_nhpi <dbl>, pop_other <dbl>, pop_two <dbl>,
#> #   vap <dbl>, vap_white <dbl>, vap_black <dbl>, vap_hisp <dbl>,
#> #   vap_aian <dbl>, vap_asian <dbl>, vap_nhpi <dbl>, vap_other <dbl>,
#> #   vap_two <dbl>, place <dbl>, id <dbl>, state <chr>, county <chr>