Are there more unique blocks in the 2020 Census than there are in the 2010 Census?

blocks_2010 <- length( unique(census_geography_2010_2020$BLK_2010) )
blocks_2020 <- length( unique(census_geography_2010_2020$BLK_2020) )

blocks_2020 - blocks_2010
## [1] -1767

Are there more unique tracts in 2020 Census than there are in the 2010 Census?

tracts_2010 <- length( unique(census_geography_2010_2020$TRACT_2010) )
tracts_2020 <- length( unique(census_geography_2010_2020$TRACT_2020) )

tracts_2020 - tracts_2010
## [1] 5118

Were there any significant county changes?

counties_distinct <- census_geography_2010_2020_blk %>%
    dplyr::select(geoid_cty_2010, COUNTY_2010, STATE_2010) %>% 
    distinct()

for (i in 1:nrow(counties_distinct)) {
    
    cty_2010 <- counties_distinct[i, "COUNTY_2010"] %>% toString()
    state_2010 <- counties_distinct[i, "STATE_2010"] %>% toString()
    
    all_blks_in_cty <- census_geography_2010_2020_blk %>% 
        dplyr::filter(COUNTY_2010 == cty_2010, STATE_2010 == state_2010)
    
    cty_2020_count <- all_blks_in_cty %>%
        count(COUNTY_2020, sort = TRUE)
    
    unique_cty_2020 <- nrow(cty_2020_count)
    
    largest_cty_name <- cty_2020_count[1, 'COUNTY_2020'] %>% toString()
    largest_cty_count <- cty_2020_count[1, 'n'] %>% as.numeric()
        
    total_2020_cty <- sum(cty_2020_count$n, na.rm = TRUE)

    largest_cty_pct <- largest_cty_count/total_2020_cty
    
    if ( (largest_cty_pct > 0.0) && (largest_cty_name != cty_2010) ) {
        diff_text <- paste(
            "\n",
            "---",
            "New County Assigment:",
            paste0("State: ", state_2010), 
            paste0("2010 County: ", cty_2010),
            paste0("2020 County: ", largest_cty_name),
            paste0("Pct. of 2010 blocks in 2020 county: ", largest_cty_pct, " (", largest_cty_count, "/", total_2020_cty, ")" ),
            sep = '\n'
        )
        cat(diff_text)
    }
    
}
## 
## 
## ---
## New County Assigment:
## State: 02
## 2010 County: 195
## 2020 County: 198
## Pct. of 2010 blocks in 2020 county: 0.580246913580247 (470/810)
## 
## ---
## New County Assigment:
## State: 02
## 2010 County: 261
## 2020 County: 063
## Pct. of 2010 blocks in 2020 county: 0.63783570300158 (1615/2532)
## 
## ---
## New County Assigment:
## State: 02
## 2010 County: 270
## 2020 County: 158
## Pct. of 2010 blocks in 2020 county: 0.999167360532889 (1200/1201)
## 
## ---
## New County Assigment:
## State: 46
## 2010 County: 113
## 2020 County: 102
## Pct. of 2010 blocks in 2020 county: 0.991898148148148 (1714/1728)
## 
## ---
## New County Assigment:
## State: 51
## 2010 County: 515
## 2020 County: 019
## Pct. of 2010 blocks in 2020 county: 1 (290/290)
changed_blks <- census_geography_2010_2020_blk %>%
    dplyr::mutate(
        part_count = ifelse(BLOCK_PART_FLAG_R == 'p', 1, 0),
        block_count = 1
    )

What counties had the most blocks change?

changed_blks %>% dplyr::group_by(geoid_cty_2010) %>%
    dplyr::summarise(
        total_blocks_in_cty = sum(block_count, na.rm = T),
        total_changed_blocks_in_cty = sum(part_count, na.rm = T),
        pct_changed = total_changed_blocks_in_cty/total_blocks_in_cty
    ) %>%
    dplyr::arrange(desc(total_changed_blocks_in_cty))
## # A tibble: 3,143 × 4
##    geoid_cty_2010 total_blocks_in_cty total_changed_blocks_in_cty pct_changed
##    <chr>                        <dbl>                       <dbl>       <dbl>
##  1 48201                        87667                       49152       0.561
##  2 06037                       119411                       42750       0.358
##  3 04013                        85341                       35118       0.412
##  4 17031                       104013                       33962       0.327
##  5 06073                        48603                       28667       0.590
##  6 06071                        53411                       24777       0.464
##  7 06029                        39587                       24094       0.609
##  8 06059                        42210                       23084       0.547
##  9 04001                        25313                       22028       0.870
## 10 53033                        40497                       19187       0.474
## # … with 3,133 more rows

What states had the most blocks change?

changed_blks %>% dplyr::group_by(geoid_st_2010) %>%
    dplyr::summarise(
        total_blocks_in_cty = sum(block_count, na.rm = T),
        total_changed_blocks_in_cty = sum(part_count, na.rm = T),
        pct_changed = total_changed_blocks_in_cty/total_blocks_in_cty
    ) %>%
    dplyr::arrange(desc(total_changed_blocks_in_cty))
## # A tibble: 51 × 4
##    geoid_st_2010 total_blocks_in_cty total_changed_blocks_in_cty pct_changed
##    <chr>                       <dbl>                       <dbl>       <dbl>
##  1 48                        1036385                      529163       0.511
##  2 06                         814735                      424972       0.522
##  3 12                         566463                      254566       0.449
##  4 51                         322635                      222540       0.690
##  5 17                         509919                      220514       0.432
##  6 29                         389948                      207424       0.532
##  7 42                         464526                      201331       0.433
##  8 39                         404900                      199483       0.493
##  9 13                         346490                      173737       0.501
## 10 40                         294515                      167644       0.569
## # … with 41 more rows
different_blks_flag <- census_geography_2010_2020_blk %>%
    dplyr::mutate(
        is_different = ifelse(geoid_2010 != geoid_2020, 1, 0),
        geoid_co_2010 = paste0(STATE_2010, COUNTY_2010),
        geoid_co_2020 = paste0(STATE_2020, COUNTY_2020)
    ) 

different_blks_flag %>%
    dplyr::group_by(geoid_co_2010) %>%
    dplyr::summarise(
        tot_blocks_is_different = sum(is_different, na.rm = T),
        tot_blocks = n(),
        pct_is_different = tot_blocks_is_different/tot_blocks
    ) %>%
    dplyr::arrange(desc(pct_is_different))
## # A tibble: 3,143 × 4
##    geoid_co_2010 tot_blocks_is_different tot_blocks pct_is_different
##    <chr>                           <dbl>      <int>            <dbl>
##  1 02105                            1088       1088                1
##  2 02261                            2532       2532                1
##  3 02270                            1201       1201                1
##  4 05049                            2071       2071                1
##  5 06003                             481        481                1
##  6 08011                            1286       1286                1
##  7 08025                             562        562                1
##  8 08027                            1287       1287                1
##  9 08047                            1006       1006                1
## 10 08091                             827        827                1
## # … with 3,133 more rows