# A tibble: 24 × 2
name label
<chr> <chr>
1 DP03_0062 Estimate!!INCOME AND BENEFITS (IN 2019 INFLATION-ADJUSTED DOLLARS…
2 DP03_0062P Percent!!INCOME AND BENEFITS (IN 2019 INFLATION-ADJUSTED DOLLARS)…
3 DP03_0086 Estimate!!INCOME AND BENEFITS (IN 2019 INFLATION-ADJUSTED DOLLARS…
4 DP03_0086P Percent!!INCOME AND BENEFITS (IN 2019 INFLATION-ADJUSTED DOLLARS)…
5 DP03_0090 Estimate!!INCOME AND BENEFITS (IN 2019 INFLATION-ADJUSTED DOLLARS…
6 DP03_0090P Percent!!INCOME AND BENEFITS (IN 2019 INFLATION-ADJUSTED DOLLARS)…
7 DP03_0092 Estimate!!INCOME AND BENEFITS (IN 2019 INFLATION-ADJUSTED DOLLARS…
8 DP03_0092P Percent!!INCOME AND BENEFITS (IN 2019 INFLATION-ADJUSTED DOLLARS)…
9 DP03_0093 Estimate!!INCOME AND BENEFITS (IN 2019 INFLATION-ADJUSTED DOLLARS…
10 DP03_0093P Percent!!INCOME AND BENEFITS (IN 2019 INFLATION-ADJUSTED DOLLARS)…
# … with 14 more rows
#population data and income datasa_acs<-get_acs(geography ="tract",state="TX",county ="Bexar",year =2019,variables=c("DP05_0001E", "DP03_0062E") ,geometry = T,output ="wide")
Getting data from the 2015-2019 5-year ACS
Warning: • You have not set a Census API key. Users without a key are limited to 500
queries per day and may experience performance limitations.
ℹ For best results, get a Census API key at
http://api.census.gov/data/key_signup.html and then supply the key to the
`census_api_key()` function to use it throughout your tidycensus session.
This warning is displayed once per session.
Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set `options(tigris_use_cache = TRUE)`.
Using the ACS Data Profile
# create a county FIPS code - 5 digitsa_acs$county<-substr(sa_acs$GEOID, 1, 5)# rename variables and filter missing casessa_acs2<-sa_acs%>%mutate(totpop= DP05_0001E,medincome=DP03_0062E) %>%st_transform(crs =2919)%>%na.omit()
library(tmap)library(tmaptools)tm_shape(sa_acs2) +tm_polygons("medincome",title="Median Household Income",palette="Purples",style="pretty", n=7 )+tm_format("World",title="San Antonio Median Household Estimates - Pretty Breaks", legend.outside=T,text.size=100)+tm_scale_bar()+tm_compass()