get_acs_data | R Documentation |
Given a map, ACS tableId, endyear and span. Prompts user for the column id if there are multiple tables. The first element of the list is a data.frame with estimates. The second element is the ACS title of the column. 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://api.census.gov/data/key_signup.html.
get_acs_data(
tableId,
map,
endyear = 2012,
span = 5,
column_idx = -1,
include_moe = FALSE
)
tableId |
The id of an ACS table |
map |
The map you want to use. Must be one of "state", "county" or "zip". |
endyear |
The end year of the survey to use. See acs.fetch (?acs.fetch) and http://1.usa.gov/1geFSSj for details. |
span |
The span of time to use. See acs.fetch and http://1.usa.gov/1geFSSj for details. on the same longitude and latitude map to scale. This variable is only checked when the "states" variable is equal to all 50 states. |
column_idx |
The optional column id of the table to use. If not specified and the table has multiple columns, you will be prompted for a column id. |
include_moe |
Whether to include the 90 percent margin of error. |
http://factfinder2.census.gov/faces/help/jsf/pages/metadata.xhtml?lang=en&type=survey&id=survey.en.ACS_ACS, which lists all ACS Surveys.
## Not run:
library(Hmisc) # for cut2
# States with greater than 1M residents
df = get_acs_data("B01003", "state")[[1]] # 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_data("B01003", "county")[[1]] # population
df$value = cut2(df$value, cuts=c(0,1000000,Inf))
county_choropleth(df, title="Counties with a population over 1M", legend="Population")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.