library(tidycensus)
library(tidyverse)
d21_in <- get_acs(
geography = "place",
variables = c("DP03_0024P"),
summary_var ="DP03_0018",
year = 2021,
survey="acs1")
#> Getting data from the 2021 1-year ACS
#> The 1-year ACS provides data for geographies with populations of 65,000 and greater.
#> Using the ACS Data Profile
d19_in <- get_acs(
geography = "place",
variables = c("DP03_0024P"),
summary_var ="DP03_0018",
year = 2019,
survey="acs1")
#> Getting data from the 2019 1-year ACS
#> The 1-year ACS provides data for geographies with populations of 65,000 and greater.
#> Using the ACS Data Profile
dtog <-
mutate(d21_in, Year=2021) %>%
bind_rows(mutate(d19_in, Year=2019)) %>%
rename(
P_wfh=estimate,
N_commute=summary_est
) %>%
pivot_wider(
id_cols=c(GEOID, NAME),
names_from=Year,
values_from=c(P_wfh, N_commute)
)
dtog %>%
ggplot(aes(x=P_wfh_2019, y=P_wfh_2021)) +
geom_point() +
geom_abline(slope=1, intercept=0) +
xlab("Percent of workers working from home in 2019") +
ylab("Percent of workers working from home in 2021")
#> Warning: Removed 68 rows containing missing values (geom_point).
dtog %>%
filter(P_wfh_2019>P_wfh_2021)
#> # A tibble: 1 x 6
#> GEOID NAME P_wfh_2021 P_wfh_2019 N_commute~1 N_com~2
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 2241155 Lake Charles city, Louisiana 2.1 4.9 35122 32419
#> # ... with abbreviated variable names 1: N_commute_2021, 2: N_commute_2019
# Most WFH
dtog %>%
arrange(desc(P_wfh_2021))
#> # A tibble: 650 x 6
#> GEOID NAME P_wfh~1 P_wfh~2 N_com~3 N_com~4
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 5357535 Redmond city, Washington 55.2 3.7 39731 40147
#> 2 2407125 Bethesda CDP, Maryland 54.5 NA 34759 NA
#> 3 0649670 Mountain View city, California 50.5 4.1 45006 49084
#> 4 0620018 Dublin city, California 50.4 NA 36915 NA
#> 5 0626000 Fremont city, California 48.9 7.1 112508 87635
#> 6 0655282 Palo Alto city, California 48.8 9.7 31007 30699
#> 7 5103000 Arlington CDP, Virginia 48.8 6.1 142653 149400
#> 8 1150000 Washington city, District of Columbia 48.3 7.4 354033 385878
#> 9 0668378 San Ramon city, California 48.1 12.8 41940 38326
#> 10 5305210 Bellevue city, Washington 48.1 9.7 74005 80373
#> # ... with 640 more rows, and abbreviated variable names 1: P_wfh_2021,
#> # 2: P_wfh_2019, 3: N_commute_2021, 4: N_commute_2019
# Least WFH
dtog %>%
arrange(P_wfh_2021)
#> # A tibble: 650 x 6
#> GEOID NAME P_wfh_2021 P_wfh_2019 N_commut~1 N_com~2
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 2241155 Lake Charles city, Louisiana 2.1 4.9 35122 32419
#> 2 0615044 Compton city, California 2.5 2 41034 41653
#> 3 0669196 Santa Maria city, California 4 3.6 47334 47292
#> 4 0664224 Salinas city, California 4.1 2.7 66919 66909
#> 5 4843888 Longview city, Texas 4.1 1.4 36893 38154
#> 6 2964550 St. Joseph city, Missouri 4.5 4.3 33494 33304
#> 7 4807000 Beaumont city, Texas 4.5 3.3 52944 53052
#> 8 4853388 Odessa city, Texas 4.7 2.5 55846 58836
#> 9 1973335 Sioux City city, Iowa 4.9 2.5 41908 41787
#> 10 0566080 Springdale city, Arkansas 5 1.8 42576 36471
#> # ... with 640 more rows, and abbreviated variable names 1: N_commute_2021,
#> # 2: N_commute_2019
# WFH in NC
dtog %>%
filter(str_detect(NAME, "North Carolina")) %>%
arrange(desc(P_wfh_2021))
#> # A tibble: 14 x 6
#> GEOID NAME P_wfh_2021 P_wfh~1 N_com~2 N_com~3
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 3710740 Cary town, North Carolina 44.2 10.9 91393 89073
#> 2 3712000 Charlotte city, North Carolina 34.6 10 469713 479292
#> 3 3755000 Raleigh city, North Carolina 33.1 10.5 245463 250448
#> 4 3719000 Durham city, North Carolina 31.6 7.2 146661 147551
#> 5 3714100 Concord city, North Carolina 24 5.5 55119 50101
#> 6 3702140 Asheville city, North Carolina 20.2 13.2 44105 47687
#> 7 3774440 Wilmington city, North Carolina 17.5 9.4 59733 58339
#> 8 3731400 High Point city, North Carolina 16.2 3 50218 50367
#> 9 3775000 Winston-Salem city, North Carolina 15.4 4.6 112701 112568
#> 10 3728000 Greensboro city, North Carolina 14.6 5.5 142655 142279
#> 11 3725580 Gastonia city, North Carolina 14.4 3.9 37552 35978
#> 12 3728080 Greenville city, North Carolina 13.5 6 41282 46211
#> 13 3734200 Jacksonville city, North Carolina 11.7 4.6 44770 41938
#> 14 3722920 Fayetteville city, North Carolina 7.3 2.5 100608 103306
#> # ... with abbreviated variable names 1: P_wfh_2019, 2: N_commute_2021,
#> # 3: N_commute_2019
Created on 2022-09-15 with reprex v2.0.2