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)

Arguments

d_from

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.

crosswalk

The crosswalk data frame, from pl_crosswalk()

Value

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().

Details

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.

Examples

# \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
# }