Description Usage Arguments Value See Also Examples
Requires the acs package to be installed, and a Census API Key to be set with the acs's api.key.install function. Census API keys can be obtained at http://www.census.gov/developers/tos/key_request.html.
1 | get_acs_df(tableId, map, endyear = 2012, span = 5, column_idx = -1)
|
tableId |
The id of an ACS table. |
map |
The map you want the data to match. Must be one of "state", "county" or "zip". |
endyear |
The end year of the survey. Defaults to 2012. |
span |
The span of the survey. Defaults to 5. |
column_idx |
An optional column index to specify. |
A data.frame.
http://factfinder2.census.gov/faces/help/jsf/pages/metadata.xhtml?lang=en&type=survey&id=survey.en.ACS_ACS, which lists all ACS Surveys.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Not run:
library(Hmisc) # for cut2
# States with greater than 1M residents
df = get_acs_df("B01003", "state") # population
df$value = cut2(df$value, cuts=c(0,1000000,Inf))
state_choropleth(df, title="States with a population over 1M", legend="Population")
# Counties with greater than or greater than 1M residents
df = get_acs_df("B01003", "county") # population
df$value = cut2(df$value, cuts=c(0,1000000,Inf))
county_choropleth(df, title="Counties with a population over 1M", legend="Population")
# ZIP codes in California where median age is between 20 and 30
df = get_acs_df("B01002", "zip") # median age
df = df[df$value >= 20 & df$value <= 30, ]
df$value = cut2(df$value, g=3) # 3 equally-sized groups
zip_map(df, title="CA Zip Codes by Age", legend="Median Age", zoom="california")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.