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(1:2, nrow(rockland), TRUE)
block2prec(rockland, rockland$id)
#> # A tibble: 2 × 24
#>   matches_id waterpct    pop pop_white pop_black pop_hisp pop_aian pop_asian
#>        <int>    <dbl>  <dbl>     <dbl>     <dbl>    <dbl>    <dbl>     <dbl>
#> 1          1     54.9 163089    103643     19762    26685      275     10073
#> 2          2     71.2 148598    100027     14861    22098      212      9026
#> # ℹ 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 <int>, state <chr>, county <chr>