You can make choropleths of selected demographic information from the US Census Bureau with the function ?zip_choropleth_acs
. It functions analogously to the other "_acs" functions in the main choroplethr package. Please see the vignette "Mapping Census Data" on the choroplethr CRAN page for additional details.
What makes zip_choropleth_acs
unique is the number of zoom options. In addition to viewing all ZIPs in the country you can select ZIPs by State, County, Metropolitan Statistical Area (MSA) as well as manually specify a number of ZIPs. Here are examples using table B19301 (per capita income):
library(choroplethrZip) # Per capita income of all ZCTAs in New York State zip_choropleth_acs("B19301", state_zoom="new york")
Note that zip_choropleth_acs
will often emit warnings because demographic information is not available for every ZCTA.
library(choroplethrZip) # zoom in on all ZCTAs in the 5 counties (boroughs) of New York City nyc_fips = c(36005, 36047, 36061, 36081, 36085) zip_choropleth_acs("B19301", county_zoom=nyc_fips)
library(choroplethrZip) # compare Manhattan's Lower East Side and Upper East Side manhattan_les = c("10002", "10003", "10009") manhattan_ues = c("10021", "10028", "10044", "10128") zip_choropleth_acs("B19301", num_colors=1, zip_zoom=c(manhattan_les, manhattan_ues))
library(choroplethrZip) # show all ZCTAs in the New York Metropolitan Statistical Area (MSA) zip_choropleth_acs("B19301", msa_zoom="New York-Newark-Jersey City, NY-NJ-PA")
Here is an example of viewing all ZCTAs in the country. While interesting to look at, this map has two problems: 1) it takes a few minutes to render and b) due to the large number (32,989) and irregular shape of ZCTAs, it can sometimes be hard to read. I have found that experimenting with the number of colors can be especially useful for this map.
zip_choropleth_acs("B19301")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.