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
#>   match…¹ water…²    pop pop_w…³ pop_b…⁴ pop_h…⁵ pop_a…⁶ pop_a…⁷ pop_n…⁸ pop_o…⁹
#>     <int>   <dbl>  <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#> 1       1    54.9 163089  103643   19762   26685     275   10073      26     325
#> 2       2    71.2 148598  100027   14861   22098     212    9026      17     284
#> # … with 14 more variables: 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>, and abbreviated variable names ¹​matches_id,
#> #   ²​waterpct, ³​pop_white, ⁴​pop_black, ⁵​pop_hisp, ⁶​pop_aian, ⁷​pop_asian,
#> #   ⁸​pop_nhpi, ⁹​pop_other