choroplethr provides native support for creating choropleths from US Census data. Note that the Census Bureau has many datasets; currently choroplethr only works with data from the American Community Survey (ACS). Internally it uses the acs package to get the data.
choroplethr has four functions for working with ACS data:
?get_acs_data
?state_choroplethr_acs
?county_choropleth_acs
To use these functions you must get and install a Census API. It is free and you can get one here. Then type the following from R:
library(acs) api.key.install('')
Note that the Census API currently only provides ACS data from 2010 onwards.
Here are some tips for getting started with ACS data:
Here is how to view population estimates for each state from the 2012 5-year ACS. Notice that the title is automatically created for you from the name of the table. Note that it is commented out because CRAN’s servers do not have a US Census API key installed.
state_choropleth_acs("B01003", endyear=2012, span=5)