R/pl_crosswalk.R
pl_retally.Rd
Applies a block crosswalk to a table of block data using areal interpolation. That is, the fraction of land area in the overlapping region between old and new blocks is used to divide the population of the old blocks into the new.
pl_retally(d_from, crosswalk)
The data frame to process. All numeric columns will be re-tallied. Integer columns will be re-tallied with rounding. Character columns will be preserved if constant across new block geometries.
The crosswalk data frame, from pl_crosswalk()
A new data frame, like d_from
, except with the geometry column
dropped, if one exists. New geometry should be loaded, perhaps with
tinytiger::tt_blocks()
.
All numeric columns will be re-tallied. Integer columns will be re-tallied with rounding. Character columns will be preserved if constant across new block geometries.
Blocks from other states will be ignored.
# \donttest{
crosswalk = pl_crosswalk("RI", 2010, 2020)
RI_2010 = pl_tidy_shp("RI", pl_url("RI", 2010), 2010)
pl_retally(RI_2010, crosswalk)
#> # A tibble: 25,649 × 24
#> GEOID state county vtd area_…¹ area_…² pop pop_h…³ pop_w…⁴ pop_b…⁵
#> <chr> <chr> <chr> <chr> <dbl> <dbl> <int> <int> <int> <int>
#> 1 44001030100… RI NA NA 5329 0 15 3 13 0
#> 2 44001030100… RI NA NA 6001 0 8 0 6 0
#> 3 44001030100… RI NA NA 11821 0 17 0 17 0
#> 4 44001030100… RI NA NA 16049 0 28 0 28 0
#> 5 44001030100… RI NA NA 5398 0 12 0 9 0
#> 6 44001030100… RI NA NA 181092 0 93 1 84 0
#> 7 44001030100… RI NA NA 17056 0 23 0 23 0
#> 8 44001030100… RI NA NA 16672 0 28 0 28 0
#> 9 44001030100… RI NA NA 7291 0 9 0 9 0
#> 10 44001030100… RI NA NA 164924 0 70 1 64 0
#> # … with 25,639 more rows, 14 more variables: pop_aian <int>, pop_asian <int>,
#> # pop_nhpi <int>, pop_other <int>, pop_two <int>, vap <int>, vap_hisp <int>,
#> # vap_white <int>, vap_black <int>, vap_aian <int>, vap_asian <int>,
#> # vap_nhpi <int>, vap_other <int>, vap_two <int>, and abbreviated variable
#> # names ¹area_land, ²area_water, ³pop_hisp, ⁴pop_white, ⁵pop_black
# }