library (ggplot2)
library (ggthemes)
Warning: package 'ggthemes' was built under R version 4.3.2
Warning: package 'socviz' was built under R version 4.3.2
Warning: package 'maps' was built under R version 4.3.2
Warning: package 'mapproj' was built under R version 4.3.2
Warning: package 'viridis' was built under R version 4.3.2
Loading required package: viridisLite
Warning: package 'viridisLite' was built under R version 4.3.2
Attaching package: 'viridis'
The following object is masked from 'package:maps':
unemp
Warning: package 'tidyverse' was built under R version 4.3.2
Warning: package 'readr' was built under R version 4.3.2
Warning: package 'dplyr' was built under R version 4.3.2
Warning: package 'stringr' was built under R version 4.3.2
Warning: package 'forcats' was built under R version 4.3.2
Warning: package 'lubridate' was built under R version 4.3.2
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr 1.1.4 ✔ readr 2.1.5
✔ forcats 1.0.0 ✔ stringr 1.5.1
✔ lubridate 1.9.3 ✔ tibble 3.2.1
✔ purrr 1.0.2 ✔ tidyr 1.3.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag() masks stats::lag()
✖ purrr::map() masks maps::map()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
Warning: package 'tidycensus' was built under R version 4.3.3
Warning: package 'leaflet' was built under R version 4.3.3
library (stringr)
census_api_key ("91d75f2026ef71780c02dbff95f245e8c42f2f15" )
To install your API key for use in future sessions, run this function with `install = TRUE`.
AR_pop <-
get_acs (geography = "county" ,
variables = "B01003_001" ,
state = "AR" ,
geometry = TRUE )
Getting data from the 2018-2022 5-year ACS
Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
|
| | 0%
|
| | 1%
|
|= | 1%
|
|= | 2%
|
|== | 2%
|
|== | 3%
|
|=== | 4%
|
|=== | 5%
|
|==== | 5%
|
|==== | 6%
|
|===== | 6%
|
|===== | 7%
|
|===== | 8%
|
|====== | 9%
|
|======= | 9%
|
|======= | 10%
|
|======== | 11%
|
|======== | 12%
|
|========= | 12%
|
|========= | 13%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 15%
|
|============ | 17%
|
|============ | 18%
|
|============= | 18%
|
|============= | 19%
|
|============== | 20%
|
|============== | 21%
|
|=============== | 21%
|
|=============== | 22%
|
|================ | 23%
|
|================ | 24%
|
|================= | 24%
|
|================= | 25%
|
|================== | 26%
|
|=================== | 27%
|
|==================== | 28%
|
|==================== | 29%
|
|===================== | 30%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 33%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 36%
|
|========================== | 37%
|
|========================== | 38%
|
|=========================== | 38%
|
|=========================== | 39%
|
|============================ | 40%
|
|============================= | 41%
|
|============================== | 42%
|
|============================== | 43%
|
|=============================== | 44%
|
|=============================== | 45%
|
|================================ | 45%
|
|================================ | 46%
|
|================================= | 47%
|
|================================= | 48%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 50%
|
|=================================== | 51%
|
|==================================== | 52%
|
|===================================== | 52%
|
|===================================== | 53%
|
|====================================== | 54%
|
|====================================== | 55%
|
|======================================= | 55%
|
|======================================= | 56%
|
|======================================== | 57%
|
|======================================== | 58%
|
|========================================= | 58%
|
|========================================= | 59%
|
|========================================== | 60%
|
|========================================== | 61%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 63%
|
|============================================= | 64%
|
|============================================== | 65%
|
|============================================== | 66%
|
|=============================================== | 67%
|
|================================================ | 68%
|
|================================================ | 69%
|
|================================================= | 70%
|
|================================================== | 71%
|
|================================================== | 72%
|
|=================================================== | 73%
|
|==================================================== | 74%
|
|===================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 77%
|
|======================================================= | 78%
|
|======================================================= | 79%
|
|======================================================== | 80%
|
|========================================================= | 81%
|
|========================================================= | 82%
|
|========================================================== | 83%
|
|=========================================================== | 84%
|
|=========================================================== | 85%
|
|============================================================ | 86%
|
|============================================================= | 87%
|
|============================================================= | 88%
|
|============================================================== | 89%
|
|=============================================================== | 89%
|
|=============================================================== | 90%
|
|================================================================ | 91%
|
|================================================================ | 92%
|
|================================================================= | 93%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 97%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 99%
|
|======================================================================| 100%
# A tibble: 6 × 6
GEOID NAME variable estimate moe geometry
<chr> <chr> <chr> <dbl> <dbl> <MULTIPOLYGON [°]>
1 05081 Little River County, … B01003_… 12024 NA (((-94.48558 33.65331, -…
2 05121 Randolph County, Arka… B01003_… 18619 NA (((-91.40687 36.49712, -…
3 05013 Calhoun County, Arkan… B01003_… 4773 NA (((-92.77672 33.53926, -…
4 05061 Howard County, Arkans… B01003_… 12779 NA (((-94.2549 34.3462, -94…
5 05099 Nevada County, Arkans… B01003_… 8292 NA (((-93.48322 33.47617, -…
6 05103 Ouachita County, Arka… B01003_… 22606 NA (((-93.11638 33.45245, -…
MapPalette <- colorQuantile (palette = "magma" , domain = AR_pop$ estimate, n = 20 )
library (sf)
Warning: package 'sf' was built under R version 4.3.3
Linking to GEOS 3.11.2, GDAL 3.8.2, PROJ 9.3.1; sf_use_s2() is TRUE
AR_pop %>%
st_transform (crs = "+proj=longlat +datum=WGS84" ) %>%
leaflet (width = "100%" , height = 500 ) %>%
addProviderTiles (provider = "Esri.WorldPhysical" ) %>%
addPolygons (popup = ~ NAME,
stroke = FALSE ,
smoothFactor = 0 ,
fillOpacity = 0.7 ,
color = ~ MapPalette (estimate)) %>%
addLegend ("bottomright" ,
pal = MapPalette,
values = ~ estimate,
title = "Population Percentiles" ,
opacity = 1 )
AR_pop %>%
st_transform (crs = "+proj=longlat +datum=WGS84" ) %>%
leaflet (width = "100%" , height = 500 ) %>%
addProviderTiles (provider = "Esri.WorldPhysical" ) %>%
addPolygons (popup = ~ NAME,
stroke = FALSE ,
smoothFactor = 0 ,
fillOpacity = 0.7 ,
color = ~ MapPalette (estimate)) %>%
addLegend ("bottomright" ,
pal = MapPalette,
values = ~ estimate,
title = "Population Percentiles" ,
opacity = 1 )