From aff914633b4f823a84c177adddf8798602e45c66 Mon Sep 17 00:00:00 2001 From: Hannah Recht Date: Tue, 2 Apr 2024 14:13:12 -0400 Subject: [PATCH] minor doc tweaks --- NEWS.md | 5 +- R/api-key.R | 3 +- R/getcensus_functions.R | 2 +- docs/articles/example-list.html | 160 ++++++++++++++++---------------- docs/news/index.html | 15 ++- docs/pkgdown.yml | 2 +- docs/reference/getCensus.html | 2 +- docs/reference/has_api_key.html | 12 ++- docs/reference/index.html | 2 +- docs/search.json | 2 +- man/getCensus.Rd | 2 +- man/has_api_key.Rd | 7 +- 12 files changed, 118 insertions(+), 96 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6dca25e..3ee2c73 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,10 +3,12 @@ * Increases required version of R from >=3.0 to >=3.5 (released in 2018) based on httr dependency. ## New features +### API keys * `getCensus()` no longer requires `key`, the use of a Census Bureau API key. Users are still encouraged to register for and use an API key because the Census Bureau may rate limit IP addresses, but it is not required. (#87) - * New `get_api_key()` helper function retrieves the value of a user's stored Census Bureau API key from a saved environment variable or provides a warning message if none is found. + +### Metadata * `listCensusApis()` now has optional `name` and `vintage` parameters to get metadata for a subset of datasets or a single dataset. (#103) ```R @@ -19,6 +21,7 @@ apis_timeseries <- listCensusApis(name = "timeseries") ## Minor improvements * `getCensus()` automatically converts data columns from the Household Pulse Survey (`name = "timeseries/hps"`) to numeric. +* New `has_api_key()` helper function detects if there is a stored Census Bureau API key in the Renviron, intended mainly for internal use. ## Documentation * Function documentation is improved and better formatted. diff --git a/R/api-key.R b/R/api-key.R index 78841ab..999adb7 100644 --- a/R/api-key.R +++ b/R/api-key.R @@ -24,9 +24,10 @@ get_api_key <- function() { key } } -#' Is there a saved API token? +#' Is there a saved Census API key in the .Renivron file? #' #' @family helpers +#' @returns TRUE or FALSE. #' @examples #' has_api_key() #' diff --git a/R/getcensus_functions.R b/R/getcensus_functions.R index aa73800..66dd765 100644 --- a/R/getcensus_functions.R +++ b/R/getcensus_functions.R @@ -146,7 +146,7 @@ getFunction <- function(apiurl, name, key, get, region, regionin, time, show_cal #' @param region Geography to get. #' @param regionin Optional hierarchical geography to limit region. #' @param key A Census API key, obtained at -#' https://api.census.gov/data/key_signup.html. If you have a `CENSUS_KEY` or +#' . If you have a `CENSUS_KEY` or #' `CENSUS_API_KEY` stored in your .Renviron file, getCensus() will #' automatically use that key. Using a key is recommended but not required. #' @param time Time period of data to get. Required for most timeseries APIs. diff --git a/docs/articles/example-list.html b/docs/articles/example-list.html index a63633e..5dce1c7 100644 --- a/docs/articles/example-list.html +++ b/docs/articles/example-list.html @@ -1319,27 +1319,27 @@

County Business Patterns23 -45 -90954 -11132 +04 +184434 +14289 23 -60 -577 -41 +05 +51809 +5939 23 -66 -5949 -371 +06 +844489 +82744 23 -69 -994 -99 +08 +178752 +20299 23 @@ -1490,7 +1490,7 @@

Nonemployer statistics -+@@ -1526,23 +1526,23 @@

Nonemployer statistics54

- - - + + + - - - + + + - - - + + + @@ -1749,11 +1749,11 @@

2020 Decennial Census

11140Americus, GA Micro Area19710220Ada, OK Micro Area237 Professional, scientific, and technical services 54
11180Ames, IA Metro Area92710300Adrian, MI Micro Area535 Professional, scientific, and technical services 54
11260Anchorage, AK Metro Area404910420Akron, OH Metro Area7190 Professional, scientific, and technical services 54
-----+++++ @@ -1785,23 +1785,23 @@

2020 Decennial Census3824

- - - + + + - - - + + + - - - + + + @@ -1944,18 +1944,6 @@

2010 Decennial CensusNA

- - - - - - - - - - - - @@ -1967,7 +1955,7 @@

2010 Decennial CensusOskaloosa, IA Micro Area

- + @@ -1979,7 +1967,7 @@

2010 Decennial CensusOttawa-Streator, IL Micro Area

- + @@ -1991,6 +1979,18 @@

2010 Decennial CensusOttumwa, IA Micro Area

+ + + + + + + + + + + +
state
23Maine199405Arkansas3825 Japanese alone or in any combination 3824
25Massachusetts2090606California469915 Japanese alone or in any combination 3824
26Michigan2376608Colorado31916 Japanese alone or in any combination 3824
36940310M100US369403657625394025394111820Owatonna, MN Micro AreaNA
36820 310M100US36820 22381NA
36860 310M100US36860 154908NA
36900 310M100US36900 35625NA
36940310M100US369403657625394025394111820Owatonna, MN Micro AreaNA
@@ -2870,14 +2870,14 @@

Health Insurance AGECAT = 1) head(sahie_adults)
- +
--++ @@ -2925,31 +2925,32 @@

Health Insurance

- - - - - + + + + + - - - - - + + + + + - - - - - + + + + + @@ -4019,10 +4020,9 @@

Public Sector Statistics2021

- - - + + + @@ -4030,10 +4030,10 @@

Public Sector Statistics2021

- - - + + + @@ -4041,10 +4041,10 @@

Public Sector Statistics2021

- - - + + + diff --git a/docs/news/index.html b/docs/news/index.html index 0a18d1a..38e194a 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -64,9 +64,16 @@

Breaking changes

New features

-
  • getCensus() no longer requires key, the use of a Census Bureau API key. Users are still encouraged to register for and use an API key because the Census Bureau may rate limit IP addresses, but it is not required. (#87)

  • -
  • New get_api_key() helper function retrieves the value of a user’s stored Census Bureau API key from a saved environment variable or provides a warning message if none is found.

  • -
  • listCensusApis() now has optional name and vintage parameters to get metadata for a subset of datasets or a single dataset. (#103)

  • +
    +

    API keys

    +
    • +getCensus() no longer requires key, the use of a Census Bureau API key. Users are still encouraged to register for and use an API key because the Census Bureau may rate limit IP addresses, but it is not required. (#87)
    • +
    • New get_api_key() helper function retrieves the value of a user’s stored Census Bureau API key from a saved environment variable or provides a warning message if none is found.
    • +
    +
    +

    Metadata

    +
    • +listCensusApis() now has optional name and vintage parameters to get metadata for a subset of datasets or a single dataset. (#103)
     
     # Get metadata for all 2020 Decennial Census datasets
    @@ -75,10 +82,12 @@ 

    New features# Get metadata for all timeseries datasets apis_timeseries <- listCensusApis(name = "timeseries")

    +

    Minor improvements

    • getCensus() automatically converts data columns from the Household Pulse Survey (name = "timeseries/hps") to numeric.
    • +
    • New has_api_key() helper function detects if there is a stored Census Bureau API key in the Renviron, intended mainly for internal use.

    Documentation

    diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 1edef71..c587515 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -7,7 +7,7 @@ articles: frequently-asked-questions: frequently-asked-questions.html getting-started: getting-started.html censusapi: censusapi.html -last_built: 2024-04-02T17:51Z +last_built: 2024-04-02T18:10Z urls: reference: https://www.hrecht.com/censusapi/reference article: https://www.hrecht.com/censusapi/articles diff --git a/docs/reference/getCensus.html b/docs/reference/getCensus.html index fbe1277..68ff064 100644 --- a/docs/reference/getCensus.html +++ b/docs/reference/getCensus.html @@ -105,7 +105,7 @@

    Argumentshttps://api.census.gov/data/key_signup.html. If you have a CENSUS_KEY or CENSUS_API_KEY stored in your .Renviron file, getCensus() will automatically use that key. Using a key is recommended but not required.

    diff --git a/docs/reference/has_api_key.html b/docs/reference/has_api_key.html index 97bcae7..aea3f6f 100644 --- a/docs/reference/has_api_key.html +++ b/docs/reference/has_api_key.html @@ -1,5 +1,5 @@ -Is there a saved API token? — has_api_key • censusapiIs there a saved Census API key in the .Renivron file? — has_api_key • censusapi @@ -52,13 +52,13 @@
    -

    Is there a saved API token?

    +

    Is there a saved Census API key in the .Renivron file?

    @@ -66,6 +66,12 @@

    Usage
    has_api_key()

    +
    +

    Value

    + + +

    TRUE or FALSE.

    +

    See also

    Other helpers: diff --git a/docs/reference/index.html b/docs/reference/index.html index 3194a20..ef6819a 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -117,7 +117,7 @@

    Helpershas_api_key() -
    Is there a saved API token?
    +
    Is there a saved Census API key in the .Renivron file?

    Datasets

    diff --git a/docs/search.json b/docs/search.json index b71e4db..7f9d31c 100644 --- a/docs/search.json +++ b/docs/search.json @@ -1 +1 @@ -[{"path":"https://www.hrecht.com/censusapi/CODE_OF_CONDUCT.html","id":null,"dir":"","previous_headings":"","what":"Contributor Code of Conduct","title":"Contributor Code of Conduct","text":"contributors maintainers project, interest fostering open welcoming community, pledge respect people contribute reporting issues, posting feature requests, updating documentation, submitting pull requests patches, activities. committed making participation project harassment-free experience everyone, regardless level experience, gender, gender identity expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, nationality. Examples unacceptable behavior participants include: use sexualized language imagery Personal attacks Trolling insulting/derogatory comments Public private harassment Publishing ’s private information, physical electronic addresses, without explicit permission unethical unprofessional conduct Project maintainers right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct. adopting Code Conduct, project maintainers commit fairly consistently applying principles every aspect managing project. Project maintainers follow enforce Code Conduct may permanently removed project team. code conduct applies within project spaces public spaces individual representing project community. Instances abusive, harassing, otherwise unacceptable behavior may reported opening issue contacting one project maintainers. Code Conduct adapted Contributor Covenant, version 1.2.0, available https://www.contributor-covenant.org/version/1/2/0/code--conduct.html","code":""},{"path":"https://www.hrecht.com/censusapi/articles/accessing-microdata.html","id":"about-microdata","dir":"Articles","previous_headings":"","what":"About microdata","title":"Accessing microdata","text":"Microdata contains individual-level responses: one row per person. vital tool perform custom analysis, great power comes great responsibility. Appropriately weighting individual-level responses required. ’ll often need work household relationships need handle responses aren’t universe question (example, removing children analysis college graduation rate.) ’re new working microdata ’ll need reading diving . resources Census Bureau: microdata use ? (video transcript) Census Microdata API User Guide (pdf) Microdata API documentation endpoints, censusapi retrieves data can perform analysis using methodology choice. ’re looking interactive microdata analysis tool, try data.census.gov microdata interactive tool IPUMS online data analysis tool. ’ve learned use microdata gained understanding weighting, getting data using censusapi simple.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/accessing-microdata.html","id":"getting-microdata-with-censusapi","dir":"Articles","previous_headings":"","what":"Getting microdata with censusapi","title":"Accessing microdata","text":"example, ’ll get data 2020 Current Population Survey Voting Supplement. survey asks people voted, , , includes useful demographic data. See available variables: CPS Voting supplement, get data method voting New York state using PES5 (Vote person mail?) PESEX (gender), along appropriate weighting variable, PWSSWGT. ’ll get data people response 1 (yes) PES1 (vote?).","code":"voting_vars <- listCensusMetadata( name = \"cps/voting/nov\", vintage = 2020, type = \"variables\") head(voting_vars) cps_voting <- getCensus( name = \"cps/voting/nov\", vintage = 2020, vars = c(\"PES5\", \"PESEX\", \"PWSSWGT\"), region = \"state:36\", PES1 = 1) head(cps_voting)"},{"path":"https://www.hrecht.com/censusapi/articles/accessing-microdata.html","id":"making-a-data-dictionary","dir":"Articles","previous_headings":"","what":"Making a data dictionary","title":"Accessing microdata","text":"microdata variables encoded, means data lot numbers instead text labels. data dictionary, includes definitions labels every variable dataset, helpful. possible listCensusMetasdata(include_values = \"TRUE) returns data dictionary one row variable-label pair. means 30 codes given variable, 30 rows data dictionary. Variables don’t value labels metadata one row. can also look meaning codes single variable using function, listCensusMetadata(). values PES5, variable “Vote person mail?”","code":"voting_dict <- listCensusMetadata( name = \"cps/voting/nov\", vintage = 2020, type = \"variables\", include_values = TRUE) head(voting_dict) PES5_values <- listCensusMetadata( name = \"cps/voting/nov\", vintage = 2020, type = \"values\", variable = \"PES5\") PES5_values"},{"path":"https://www.hrecht.com/censusapi/articles/accessing-microdata.html","id":"other-ways-to-access-microdata","dir":"Articles","previous_headings":"","what":"Other ways to access microdata","title":"Accessing microdata","text":"Census Bureau microdata APIs helpful working limited just-released datasets. ’re option. ways get microdata : Retrieve standardized, cleaned microdata data IPUMS import impumsr package. IPUMS widely used research data needed brand new. highly recommend check IPUMS’ cleaned files microdata files well historic geographic data. standardized files generally released months year raw Census microdata available directly Census Bureau. Download complete bulk files Census FTPs (file transfer protocols.) helpful need large number variables. might run size limitations getting many variables APIs. Retrieve American Community Survey microdata via Census APIs tidycensus, helpful functions working endpoints.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"american-community-survey","dir":"Articles","previous_headings":"","what":"American Community Survey","title":"censusapi examples","text":"multiple useful ACS datasets slightly different purposes. ’s Census Bureau describes :","code":"\"Detailed Tables contain the most detailed cross-tabulations, many of which are published down to block groups. The data are population counts. There are over 20,000 variables in this dataset. Subject Tables provide an overview of the estimates available in a particular topic. The data are presented as population counts and percentages. There are over 18,000 variables in this dataset. Data Profiles contain broad social, economic, housing, and demographic information. The data are presented as population counts and percentages. There are over 1,000 variables in this dataset. Comparison Profiles are similar to Data Profiles but also include comparisons with past-year data. The current year data are compared with prior 5-Year data and include statistical significance testing. There are over 1,000 variables in this dataset.\""},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"acs-detailed-tables","dir":"Articles","previous_headings":"American Community Survey","what":"ACS Detailed Tables","title":"censusapi examples","text":"Get total population median income places (towns, cities, etc) Indiana.","code":"acs_income <- getCensus( name = \"acs/acs5\", vintage = 2022, vars = c(\"NAME\", \"B01001_001E\", \"B19013_001E\"), region = \"place:*\", regionin = \"state:18\") head(acs_income)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"acs-subject-tables","dir":"Articles","previous_headings":"American Community Survey","what":"ACS Subject Tables","title":"censusapi examples","text":"Get percent people without internet subscription income five counties New York City, associated margins error: overall: S2801_C02_019E income less $20,000: S2801_C02_023E income $20,000 $74,999: S2801_C02_027E income $75,000 greater: S2801_C02_031E","code":"acs_subject <- getCensus( name = \"acs/acs1/subject\", vintage = 2022, vars = c(\"NAME\", \"S2801_C02_019E\", \"S2801_C02_019M\", \"S2801_C02_023E\", \"S2801_C02_023M\", \"S2801_C02_027E\", \"S2801_C02_027M\", \"S2801_C02_031E\", \"S2801_C02_031M\"), region = \"county:005,047,061,081,085\", regionin = \"state:36\") head(acs_subject)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"acs-comparison-profiles","dir":"Articles","previous_headings":"American Community Survey","what":"ACS Comparison Profiles","title":"censusapi examples","text":"Get annual median household income inflation-adjusted 2019 dollars Alabama cities since 2018. (2020 1-year data available.)","code":"acs_comparison <- getCensus( name = \"acs/acs1/cprofile\", vintage = 2022, vars = c(\"NAME\", \"CP03_2018_062E\", \"CP03_2019_062E\", \"CP03_2021_062E\", \"CP03_2022_062E\"), region = \"place:*\", regionin = \"state:01\") head(acs_comparison)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"acs-migration-flows","dir":"Articles","previous_headings":"American Community Survey","what":"ACS Migration Flows","title":"censusapi examples","text":"American Community Survey Migration Flows documentation Get number people moved Los Angeles county origin destination.","code":"flows <- getCensus( name = \"acs/flows\", vintage = 2019, vars = c(\"MOVEDIN\", \"MOVEDOUT\", \"GEOID2\", \"FULL1_NAME\", \"FULL2_NAME\"), region = \"county:037\", regionin = \"state:06\") head(flows, n = 15L)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"american-community-survey-language-statistics","dir":"Articles","previous_headings":"American Community Survey","what":"American Community Survey Language Statistics","title":"censusapi examples","text":"American Community Survey Language Statistics documentation Get number people New York state speak language.","code":"languages <- getCensus( name = \"language\", vintage = 2013, vars = c(\"EST\", \"LAN\", \"LANLABEL\"), region = \"state:36\") head(languages)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"annual-survey-of-entrepreneurs","dir":"Articles","previous_headings":"","what":"Annual Survey of Entrepreneurs","title":"censusapi examples","text":"Annual Survey Entrepreneurs documentation","code":"ase_csa <- getCensus( name = \"ase/csa\", vintage = 2014, vars = c(\"GEO_TTL\", \"NAICS2012\", \"NAICS2012_TTL\", \"EMPSZFI\", \"EMPSZFI_TTL\", \"FIRMPDEMP\"), region = \"us:*\") head(ase_csa) ase_cscb <- getCensus( name = \"ase/cscb\", vintage = 2014, vars = c(\"GEO_TTL\", \"NAICS2012_TTL\", \"ASECB\", \"ASECB_TTL\", \"SPOUSES\", \"SPOUSES_TTL\", \"YEAR\", \"FIRMPDEMP\", \"FIRMPDEMP_PCT\", \"RCPPDEMP\", \"RCPPDEMP_F\", \"RCPPDEMP_PCT\", \"EMP\", \"EMP_PCT\", \"PAYANN\", \"PAYANN_PCT\", \"FIRMPDEMP_S\", \"FIRMPDEMP_PCT_S\", \"RCPPDEMP_S\", \"RCPPDEMP_PCT_S\", \"EMP_S\", \"EMP_PCT_S\", \"PAYANN_S\", \"PAYANN_PCT_S\"), region = \"us:*\") head(ase_cscb) ase_cscbo <- getCensus( name = \"ase/cscbo\", vintage = 2014, vars = c(\"GEO_TTL\", \"NAICS2012_TTL\", \"ASECBO\", \"ASECBO_TTL\", \"ACQBUS\", \"ACQBUS_TTL\", \"YEAR\", \"OWNPDEMP\", \"OWNPDEMP_PCT\", \"OWNPDEMP_S\", \"OWNPDEMP_PCT_S\"), region = \"us:*\") head(ase_cscbo)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"annual-survey-of-manufactures","dir":"Articles","previous_headings":"","what":"Annual Survey of Manufactures","title":"censusapi examples","text":"Annual Survey Manufactures documentation","code":"asm_state <- getCensus( name = \"timeseries/asm/state\", vars = c(\"GEO_TTL\", \"NAICS_TTL\", \"EMP\"), region = \"state:*\", time = 2016, NAICS = \"31-33\") head(asm_state) asm_product <- getCensus( name = \"timeseries/asm/product\", vars = c(\"PSCODE_TTL\", \"GEO_TTL\", \"PRODVAL\"), region = \"us:*\", time = 2016, PSCODE = 311111) head(asm_product)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"community-resiliency-estimates","dir":"Articles","previous_headings":"","what":"Community Resiliency Estimates","title":"censusapi examples","text":"Community Resilience Estimates documentation Census tracts single county, get rate individuals zero components social vulnerability, one-two components social vulnerability, three components social vulnerability.","code":"cre <- getCensus( name = \"cre\", vintage = 2022, vars = c(\"PRED0_PE\", \"PRED12_PE\", \"PRED3_PE\"), region = \"tract:*\", regionin = \"state:01&county:001\") head(cre)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"county-business-patterns-and-nonemployer-statistics","dir":"Articles","previous_headings":"","what":"County Business Patterns and Nonemployer Statistics","title":"censusapi examples","text":"County Business Patterns Nonemployer Statistics documentation","code":""},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"county-business-patterns","dir":"Articles","previous_headings":"County Business Patterns and Nonemployer Statistics","what":"County Business Patterns","title":"censusapi examples","text":"County Business Patterns documentation Get employment data construction industry. Get number companies employees organizations 1,000 employees (EMPSZES = 260).","code":"cbp <- getCensus( name = \"cbp\", vintage = 2021, vars = c(\"EMP\", \"ESTAB\"), region = \"state:*\", NAICS2017 = 23) head(cbp) cbp_large_companies <- getCensus( name = \"cbp\", vintage = 2021, vars = c(\"NAME\", \"EMP\", \"ESTAB\"), region = \"state:*\", EMPSZES = 260) head(cbp_large_companies)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"zip-codes-business-patterns","dir":"Articles","previous_headings":"County Business Patterns and Nonemployer Statistics","what":"Zip Codes Business Patterns","title":"censusapi examples","text":"Zip Codes Business Patterns documentation","code":"zbp_2018 <- getCensus( name = \"zbp\", vintage = 2018, vars = c(\"EMP\", \"ESTAB\", \"EMPSZES\"), region = \"zipcode:90210\") head(zbp_2018)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"nonemployer-statistics","dir":"Articles","previous_headings":"County Business Patterns and Nonemployer Statistics","what":"Nonemployer statistics","title":"censusapi examples","text":"Nonemployer statistics documentation Get number nonemployer establishments MSA sector 54, Professional, scientific, technical services.","code":"nonemp <- getCensus( name = \"nonemp\", vintage = 2021, vars = c(\"NAME\", \"NESTAB\", \"NAICS2017_LABEL\"), region = \"metropolitan statistical area/micropolitan statistical area:*\", NAICS2017 = 54) head(nonemp)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"decennial-census","dir":"Articles","previous_headings":"","what":"Decennial Census","title":"censusapi examples","text":"Decennial Census documentation","code":""},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"decennial-census-1","dir":"Articles","previous_headings":"Decennial Census","what":"2020 Decennial Census","title":"censusapi examples","text":"Using 2020 Demographic Profile, get percent population age 65 older (DP1_0024P) metro micropolitan statistical areas. Using 2020 Demographic Housing Characteristics File, get total number households (H9_001N) number 1-person households (H9_002N) counties Maryland. can use Detailed Demographic Housing Characteristics File (Detailed DHC-) get detailed data specific race ethnicity groups. First, check value labels POPGROUP variable. Get total population (T01001_001N) people Japanese alone combination (POPGROUP code 3824) state.","code":"dec_elderly <- getCensus( name = \"dec/dp\", vintage = 2020, vars = c(\"NAME\", \"DP1_0024P\"), region = \"metropolitan statistical area/micropolitan statistical area:*\") head(dec_elderly) dec <- getCensus( name = \"dec/dhc\", vintage = 2020, vars = c(\"NAME\", \"H9_001N\", \"H9_002N\"), region = \"county:*\", regionin = \"state:24\") head(dec) popgroup_values <- listCensusMetadata( name = \"dec/ddhca\", vintage = 2020, type = \"values\", variable_name = \"POPGROUP\") head(popgroup_values) dec_population <- getCensus( name = \"dec/ddhca\", vintage = 2020, vars = c(\"NAME\", \"T01001_001N\", \"POPGROUP_LABEL\"), region = \"state:*\", POPGROUP = 3824) head(dec_population)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"decennial-census-2","dir":"Articles","previous_headings":"Decennial Census","what":"2010 Decennial Census","title":"censusapi examples","text":"Get total population number housing units metropolitan/micropolitan statistical areas 2010. Get urban/rural status group variables (P2) metropolitan/micropolitan statistical areas 2010. Get 2010 population block group within specific tract.","code":"data2010 <- getCensus( name = \"dec/sf1\", vintage = 2010, vars = c(\"NAME\", \"P001001\", \"H010001\"), region = \"metropolitan statistical area/micropolitan statistical area:*\") head(data2010) # Show variable metadata for the P2 group group_p2 <- listCensusMetadata( name = \"dec/sf1\", vintage = 2010, type = \"variables\", group = \"P2\") # Get the P2 variable group (URBAN AND RURAL) data2010 <- getCensus( name = \"dec/sf1\", vintage = 2010, vars = \"group(P2)\", region = \"metropolitan statistical area/micropolitan statistical area:*\") head(data2010) tract_pop <- getCensus( name = \"dec/sf1\", vintage = 2010, vars = \"P001001\", region = \"block:*\", regionin = \"state:36+county:027+tract:010000\") head(tract_pop)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"decennial-census-self-response-rates","dir":"Articles","previous_headings":"Decennial Census","what":"Decennial Census Self-Response Rates","title":"censusapi examples","text":"Decennial Census Self-Response Rates documentation Get self-response rates 2020 2010 Decennial Census state, county, tract, place . Get overall internet repose rates counties. Get response rates places (cities, towns, etc) within New York state. Get final 2010 Decennial Census self-response rates.","code":"county_responses <- getCensus( name = \"dec/responserate\", vintage = 2020, vars = c(\"NAME\", \"RESP_DATE\", \"CRRALL\", \"CRRINT\"), region = \"county:*\") head(county_responses) ny_place_responses <- getCensus( name = \"dec/responserate\", vintage = 2020, vars = c(\"NAME\", \"RESP_DATE\", \"CRRALL\", \"CRRINT\"), region = \"place:*\", regionin = \"state:36\") head(ny_place_responses) county_responses_2010 <- getCensus( name = \"dec/responserate\", vintage = 2010, vars = c(\"NAME\", \"FSRR2010\"), region = \"county:*\") head(county_responses_2010)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"decennial-census-surname-files","dir":"Articles","previous_headings":"Decennial Census","what":"Decennial Census Surname Files","title":"censusapi examples","text":"Decennial Census Surname documentation Get counts top 25 popular surnames share race.","code":"top_surnames <- getCensus( name = \"surname\", vintage = 2010, vars = c(\"NAME\", \"COUNT\", \"PROP100K\", \"PCTWHITE\", \"PCTBLACK\", \"PCTAIAN\", \"PCTAPI\", \"PCTHISPANIC\", \"PCT2PRACE\"), RANK = \"1:25\") head(top_surnames)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"economic-census","dir":"Articles","previous_headings":"","what":"Economic Census","title":"censusapi examples","text":"Economic Census documentation","code":"ewks_2012 <- getCensus( name = \"ewks\", vintage = 2012, vars = c(\"EMP\", \"OPTAX\", \"GEOTYPE\"), region = \"state:*\", NAICS2012 = 54) head(ewks_2012) ewks_2007 <- getCensus( name = \"ewks\", vintage = 2007, vars = c(\"EMP\", \"OPTAX\", \"GEOTYPE\"), region = \"state:*\", NAICS2007 = 54) head(ewks_2007)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"economic-indicators","dir":"Articles","previous_headings":"","what":"Economic Indicators","title":"censusapi examples","text":"Economic Indicators documentation","code":"eits <- getCensus( name = \"timeseries/eits/resconst\", vars = c(\"cell_value\", \"data_type_code\", \"time_slot_id\", \"error_data\", \"category_code\", \"seasonally_adj\"), region = \"us:*\", time = \"from 2023-01\") head(eits)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"health-insurance-small-area-health-insurance-estimates","dir":"Articles","previous_headings":"","what":"Health Insurance: Small Area Health Insurance Estimates","title":"censusapi examples","text":"Health Insurance Statistics documentation Get uninsured rate income group county single year. Get uninsured rate county 2006 latest year available. Get uninsured rate non-elderly adults (AGECAT = 1) incomes 138 400% poverty line (IPRCAT = 5), race state.","code":"sahie <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"IPRCAT\", \"IPR_DESC\", \"PCTUI_PT\"), region = \"county:*\", time = 2021) head(sahie) sahie_annual <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"PCTUI_PT\"), region = \"county:037\", regionin = \"state:06\", time = \"from 2006\") sahie_annual sahie_adults <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"PCTUI_PT\", \"RACECAT\", \"RACE_DESC\"), region = \"state:*\", time = 2021, IPRCAT = 5, AGECAT = 1) head(sahie_adults)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"household-pulse-survey","dir":"Articles","previous_headings":"","what":"Household Pulse Survey","title":"censusapi examples","text":"Household Pulse Survey documentation Get food scarcity rate (Percentage adults households either sometimes often enough eat last 7 days) expense difficulty rate (Percentage adults households somewhat difficult pay usual household expenses last 7 days) every state one survey period. Get national food scarcity rate expense difficulty rate every survey period available since 2022.","code":"hps_state <- getCensus( name = \"timeseries/hps\", vars = c(\"NAME\", \"FOODSCARCE_RATE\", \"EXPENSE_RATE\", \"COL_START_DATE\", \"COL_END_DATE\"), region = \"state:*\", WEEK = 63, time = 2023) head(hps_state) hps_us <- getCensus( name = \"timeseries/hps\", vars = c(\"FOODSCARCE_RATE\", \"EXPENSE_RATE\", \"COL_START_DATE\", \"COL_END_DATE\"), region = \"us:*\", WEEK = \"*\", time = \"from 2022\") hps_us"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"international-data-base","dir":"Articles","previous_headings":"","what":"International Data Base","title":"censusapi examples","text":"International Data Base documentation Get Census Bureau projections 2024 populations life expectancy birth country.","code":"intl_pop <- getCensus( name = \"timeseries/idb/5year\", vars = c(\"NAME\", \"GENC\", \"POP\", \"E0\"), time = 2024) head(intl_pop)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"international-trade","dir":"Articles","previous_headings":"","what":"International Trade","title":"censusapi examples","text":"International Trade documentation Note: international trade datasets can buggy often give general error message “error running query. ’ve logged error ’ll correct ASAP. Sorry inconvenience.” error message comes U.S. Census Bureau. run repeated issues inconsistencies, contact Census Bureau help consider using bulk data download instead. Get general imports value imports consumption value countries specific month.","code":"imports <- getCensus( name = \"timeseries/intltrade/imports/enduse\", vars = c(\"CTY_CODE\", \"CTY_NAME\", \"GEN_VAL_MO\", \"CON_VAL_MO\"), time = \"2024-01\") head(imports)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"population-estimates-and-projections","dir":"Articles","previous_headings":"","what":"Population Estimates and Projections","title":"censusapi examples","text":"Population Estimates Projections documentation","code":""},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"population-estimates","dir":"Articles","previous_headings":"Population Estimates and Projections","what":"Population Estimates","title":"censusapi examples","text":"Population Estimates documentation PEP data 2022 beyond currently available via API. can download latest data files PEP webpage. Get 2021 vintage population estimates states 2020 2021.","code":"popest <- getCensus( name = \"pep/population\", vintage = 2021, vars = c(\"POP_2020\",\"POP_2021\"), region = \"state:*\") head(popest) popest_housing <- getCensus( name = \"pep/housing\", vintage = 2018, vars = c(\"DATE_CODE\", \"DATE_DESC\", \"HUEST\"), region = \"county:195\", regionin = \"state:02\") head(popest_housing)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"population-projections","dir":"Articles","previous_headings":"Population Estimates and Projections","what":"Population Projections","title":"censusapi examples","text":"Population Projections documentation","code":"popproj <- getCensus( name = \"pep/projpop\", vintage = 2014, vars = c(\"YEAR\", \"POP\", \"AGE\"), region = \"us:1\") head(popproj)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"poverty-statistics","dir":"Articles","previous_headings":"","what":"Poverty Statistics","title":"censusapi examples","text":"Poverty Statistics documentation","code":""},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"current-population-survey-poverty-statistics","dir":"Articles","previous_headings":"Poverty Statistics","what":"Current Population Survey Poverty Statistics","title":"censusapi examples","text":"Get national poverty rates race since 1970.","code":"poverty <- getCensus( name = \"timeseries/poverty/histpov2\", vars = c(\"RACE\", \"RACE_LABEL\", \"PCTPOV\"), region = \"us:*\", time = \"from 1970\") head(poverty)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"small-area-income-and-poverty-estimates-saipe","dir":"Articles","previous_headings":"Poverty Statistics","what":"Small Area Income and Poverty Estimates (SAIPE)","title":"censusapi examples","text":"Get poverty rate children overall single year. Get poverty rate children overall single county time.","code":"saipe <- getCensus( name = \"timeseries/poverty/saipe\", vars = c(\"NAME\", \"SAEPOVRT0_17_PT\", \"SAEPOVRTALL_PT\"), region = \"state:*\", time = 2022) head(saipe) saipe_years <- getCensus( name = \"timeseries/poverty/saipe\", vars = c(\"NAME\", \"SAEPOVRT0_17_PT\", \"SAEPOVRTALL_PT\"), region = \"county:001\", regionin = \"state:12\", time = \"from 2010\") head(saipe_years)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"saipe-school-districts","dir":"Articles","previous_headings":"Poverty Statistics","what":"SAIPE School Districts","title":"censusapi examples","text":"Get number (SAEPOV5_17V_PT) rate (SAEPOVRAT5_17RV_PT) children ages 5-17 living poverty unified school districts Massachusetts.","code":"saipe_schools <- getCensus( name = \"timeseries/poverty/saipe/schdist\", vars = c(\"SD_NAME\", \"SAEPOV5_17V_PT\", \"SAEPOVRAT5_17RV_PT\"), region = \"school district (unified):*\", regionin = \"state:25\", time = 2022) head(saipe_schools)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"public-sector-statistics","dir":"Articles","previous_headings":"","what":"Public Sector Statistics","title":"censusapi examples","text":"Public Sector Statistics documentation endpoint includes data multiple surveys organized sure read Census Bureau’s documentation variable definitions labels. Get expenditures Public Elementary-Secondary School System Finances Massachusetts.","code":"govs <- getCensus( name = \"timeseries/govs\", vars = c(\"SVY_COMP_LABEL\", \"AGG_DESC\", \"AGG_DESC_LABEL\" ,\"AMOUNT\"), region = \"state:25\", time = 2021, SVY_COMP = \"06\", EXPENDTYPE = \"001\") head(govs)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"quarterly-workforce-indicators","dir":"Articles","previous_headings":"","what":"Quarterly Workforce Indicators","title":"censusapi examples","text":"Quarterly Workforce Indicators documentation QWI endpoints allow simple calls specific ones. Make sure read documentation closely. ’s simple call gets employment data county. Got total employment average earnings quarter single state. ’s much specific call. Read Census Bureau’s documentation closely see options allowed QWI APIs.","code":"qwi_counties <- getCensus( name = \"timeseries/qwi/sa\", vars = c(\"Emp\", \"EarnBeg\"), region = \"county:*\", regionin = \"state:01\", time = \"2023-Q2\") head(qwi_counties) qwi_time <- getCensus( name = \"timeseries/qwi/sa\", vars = c(\"Emp\", \"EarnBeg\"), region = \"state:01\", time = \"from 2018 to 2023\") head(qwi_time) qwi <- getCensus( name = \"timeseries/qwi/sa\", region = \"state:02\", vars = c(\"Emp\", \"sex\"), time = 2012, quarter = 1, agegrp = \"A07\", ownercode = \"A05\", firmsize = 1, seasonadj = \"U\", industry = 21) qwi"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"the-planning-database","dir":"Articles","previous_headings":"","what":"The Planning Database","title":"censusapi examples","text":"Planning Database documentation Get population 2010 Census mail return rates block groups Autauga County, AL.","code":"pdb <- getCensus( name = \"pdb/blockgroup\", vintage = 2018, vars = c(\"GIDBG\", \"County_name\", \"State_name\", \"Tot_Population_CEN_2010\", \"Mail_Return_Rate_CEN_2010\"), region = \"block group:*\", regionin = \"state:01+county:001\") head(pdb)"},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"how-do-i-learn-more-about-a-particular-dataset","dir":"Articles","previous_headings":"","what":"How do I learn more about a particular dataset?","title":"Frequently asked questions","text":"Read online documentation survey. information included developer metadata documentation pages available PDFs Census Bureau website.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"how-can-i-see-the-underlying-api-call-sent-to-the-census-bureau","dir":"Articles","previous_headings":"","what":"How can I see the underlying API call sent to the Census Bureau?","title":"Frequently asked questions","text":"can see underlying API call sent Census Bureau servers setting getCensus(show_call = TRUE) running code. getCensus() call results error, automatically print underlying API call R console. can copy paste URL web browser view directly.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"what-does-there-was-an-error-while-running-your-query-mean","dir":"Articles","previous_headings":"","what":"What does “There was an error while running your query” mean?","title":"Frequently asked questions","text":"Occasionally might get general error message “error running query. logged error correct ASAP. Sorry inconvenience.” comes Census Bureau caused number problems, including server issues. Try rerunning API call. doesn’t work requesting large amount data, try reducing amount ’re requesting. ’re still trouble, see ways get help.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"my-getcensus-call-worked-last-year-but-now-it-gives-an-error--why","dir":"Articles","previous_headings":"","what":"My getCensus() call worked last year but now it gives an error. Why?","title":"Frequently asked questions","text":"Census Bureau makes frequent changes APIs. annual datasets, like American Community Survey, variable names available geographies can change year year. Options timeseries datasets sometimes change new releases. Check Census Bureau’s online documentation dataset use listCensusMetadata() make sure ’re using current syntax.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"are-the-census-apis-case-sensitive","dir":"Articles","previous_headings":"","what":"Are the Census APIs case sensitive?","title":"Frequently asked questions","text":"Yes. Run listCensusMetadata(type = \"variables\") dataset see variables available. variable name want uppercase ’ll need write uppercase getCensus() request. APIs use uppercase, use lowercase even use sentence case variable names.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"how-do-i-know-what-geographies-are-available-for-my-dataset-what-is-a-fips-code","dir":"Articles","previous_headings":"","what":"How do I know what geographies are available for my dataset? What is a FIPS code?","title":"Frequently asked questions","text":"Run listCensusMetadata(type = \"geographies\") dataset check geographies can use. API list valid geographies occasionally change Census Bureau makes updates. geographies Census APIs specified using FIPS (Federal Information Processing Standards) codes. example, Autauga County, Alabama assigned state code 01 county code 001. combined GEOID, uniquely identifies counties nationally, 01001. See Census Bureau FIPS reference valid codes geographic glossary information. can also download geographic identifying information Census gazetteer files, including full GEOID, name, centroid coordinates. FIPS codes characters, numbers. example, state-level FIPS codes two characters long. region = state:01 work region =``state:1 usually .","code":""},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"how-do-i-get-data-for-every-state-county-or-metro-area","dir":"Articles","previous_headings":"","what":"How do I get data for every state, county, or metro area?","title":"Frequently asked questions","text":"Census datasets allow use wildcard — * symbol — get data geography class. example, can get data every state American Community Survey using region = state:*. Data small geographies, like Census tract block group, need nested using regionin argument. Run listCensusMetadata(type = \"geographies\") see options. ’s example getting block group population data within specific Census tract using 2020 Decennial Census.","code":"state_data <- getCensus( name = \"acs/acs1\", vintage = 2022, vars = c(\"NAME\", \"B19013_001E\"), region = \"state:*\") head(state_data) block_group <- getCensus( name = \"dec/dhc\", vintage = 2020, vars = c(\"NAME\", \"P1_001N\"), region = \"block group:*\", regionin = \"state:36+county:027+tract:220300\") block_group"},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"im-still-stuck-or-got-an-unexpected-result--how-can-i-get-help","dir":"Articles","previous_headings":"","what":"I’m still stuck or got an unexpected result. How can I get help?","title":"Frequently asked questions","text":"Use listCensusMetadata() make sure ’re using right variable names /geography names. Join Census Bureau’s public Slack channel ask question R API rooms. Census Bureau staff censusapi users (censusapi package developer!) check Slack regularly. fastest way get help. Open Github issue bugs issues suspect caused R package. questions specific survey, can email contact listed dataset metadata found listCensusApis().","code":""},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"why-is-my-data--666666666-or-another-weird-value-what-is-an-annotation","dir":"Articles","previous_headings":"","what":"Why is my data -666666666 or another weird value? What is an annotation?","title":"Frequently asked questions","text":"Census datasets, including American Community Survey, use annotated values. values use numbers symbols indicate data unavailable, top coded, insufficient sample size, noteworthy characteristics. Read Census Bureau ACS annotation meanings ACS variable types. censusapi package intended return data -can receive unaltered annotations. using data small geography like Census tract block group make sure check values like -666666666 check annotation columns non-empty values exclude needed. example, ’ll get total number households (B11012_001E) median household income associated annotations margins error (B19013 group) three census tracts Washington, DC. value one tract available, one top coded, one unavailable. Notice income top coded $250,000 — meaning tract’s income threshold listed $250,001. can see value special meaning “EA” (estimate annotation) “MA” (margin error annotation) columns.","code":"annotations_example <- getCensus( name = \"acs/acs5\", vintage = 2022, vars = c(\"B11012_001E\", \"group(B19013)\"), region = \"tract:006804,007703,000903\", regionin = \"county:001&state:11\") annotations_example"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"api-key-setup","dir":"Articles","previous_headings":"","what":"API key setup","title":"Getting started with censusapi","text":"censusapi recommends require using API key U.S. Census Bureau. Census Bureau may limit number requests made IP address use API key. can sign online receive key, sent provided email address. save key name CENSUS_KEY CENSUS_API_KEY Renviron file, censusapi use default without extra work part. save API key, within R, run: instances might want put key .Renviron - example, ’re shared school computer. can always choose manually set key = \"PASTEYOURKEYHERE\" argument getCensus() prefer.","code":"# Check to see if you already have a CENSUS_KEY or CENSUS_API_KEY saved # If so, no further action is needed get_api_key() # If not, add your key to your Renviron file Sys.setenv(CENSUS_KEY=PASTEYOURKEYHERE) # Reload .Renviron readRenviron(\"~/.Renviron\") # Check to see that the expected key is output in your R console get_api_key()"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"basic-usage","dir":"Articles","previous_headings":"","what":"Basic usage","title":"Getting started with censusapi","text":"main function censusapi getCensus(), makes API call given endpoint returns data frame results. API slightly different parameters, always required arguments: name: programmatic name endpoint defined Census, like “acs/acs5” “timeseries/bds/firms” vintage: survey year, required aggregate microdata APIs vars: list variables retrieve region: geography level retrieve, state county, required nearly endpoints APIs additional required optional arguments, like time timeseries datasets. Check specific documentation API explore metadata listCensusMetadata() see options allowed. Let’s walk example getting uninsured rates using Small Area Health Insurance Estimates API, provides detailed annual state-level county-level estimates health insurance rates people age 65.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"choosing-variables","dir":"Articles","previous_headings":"Basic usage","what":"Choosing variables","title":"Getting started with censusapi","text":"censusapi includes metadata function called listCensusMetadata() get information API’s variable geography options. Let’s see variables available SAHIE API:","code":"library(censusapi) sahie_vars <- listCensusMetadata( name = \"timeseries/healthins/sahie\", type = \"variables\") # See the full list of variables sahie_vars$name #> [1] \"for\" \"in\" \"time\" \"NIPR_LB90\" \"NIPR_PT\" #> [6] \"AGECAT\" \"GEOID\" \"NIC_PT\" \"STATE\" \"RACE_DESC\" #> [11] \"YEAR\" \"IPRCAT\" \"PCTIC_UB90\" \"NIPR_MOE\" \"PCTUI_LB90\" #> [16] \"NIC_MOE\" \"US\" \"COUNTY\" \"PCTUI_MOE\" \"NUI_UB90\" #> [21] \"NIC_UB90\" \"NUI_MOE\" \"SEXCAT\" \"PCTUI_PT\" \"PCTIC_LB90\" #> [26] \"PCTUI_UB90\" \"NUI_PT\" \"STABREV\" \"AGE_DESC\" \"NAME\" #> [31] \"NIC_LB90\" \"PCTIC_PT\" \"PCTIC_MOE\" \"IPR_DESC\" \"NUI_LB90\" #> [36] \"NIPR_UB90\" \"GEOCAT\" \"SEX_DESC\" \"RACECAT\" # Full info on the first several variables head(sahie_vars)"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"choosing-regions","dir":"Articles","previous_headings":"Basic usage","what":"Choosing regions","title":"Getting started with censusapi","text":"can also use listCensusMetadata see geographic levels available. API three geographic levels: us, county, state. County data can queried counties nationally within specific state.","code":"listCensusMetadata( name = \"timeseries/healthins/sahie\", type = \"geographies\")"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"making-a-censusapi-call","dir":"Articles","previous_headings":"Basic usage","what":"Making a censusapi call","title":"Getting started with censusapi","text":"First, using getCensus(), let’s get percent (PCTUI_PT) number (NUI_PT) people uninsured, using wildcard star (*) retrieve data counties. can also get data detailed income demographic groups SAHIE. ’ll use region specify county-level results regionin filter Virginia, state code 51. ’ll get uninsured rates income group, IPRCAT. SAHIE API timeseries dataset, indicated name,, can get multiple years data changing time = YYYY time = \"YYYY YYYY\", get latest data available using time = \"YYYY\". Let’s get data DeKalb County, Georgia using county fips code 089 state fips code 13. can look fips codes Census Bureau website. can also filter data income group using IPRCAT variable. See possible values IPRCAT using listCensusMetadata(). IPRCAT = 3 represents <=138% federal poverty line. threshold Medicaid eligibility states expanded Affordable Care Act. Getting data Los Angeles county (fips code 06037) can see dramatic decrease uninsured rate income group California expanded Medicaid.","code":"sahie_counties <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"PCTUI_PT\", \"NUI_PT\"), region = \"county:*\", time = 2021) head(sahie_counties) sahie_virginia <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"IPRCAT\", \"IPR_DESC\", \"PCTUI_PT\"), region = \"county:*\", regionin = \"state:51\", time = 2021) head(sahie_virginia, head = 12L) sahie_years <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"PCTUI_PT\"), region = \"county:089\", regionin = \"state:13\", time = \"from 2006\") sahie_years listCensusMetadata( name = \"timeseries/healthins/sahie\", type = \"values\", variable = \"IPRCAT\") sahie_138 <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"PCTUI_PT\", \"NUI_PT\"), region = \"county:037\", regionin = \"state:06\", IPRCAT = 3, time = \"from 2010\") sahie_138"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"finding-your-api","dir":"Articles","previous_headings":"","what":"Finding your API","title":"Getting started with censusapi","text":"don’t already know dataset’s name? see current table every available endpoint, use listCensusApis(). data frame includes useful information making API call, including dataset’s name, vintage applicable, description, title. can also get information subset datasets using optional name /vintage parameters. example, get information 2020 Decennial Census datasets.","code":"apis <- listCensusApis() colnames(apis) #> [1] \"title\" \"name\" \"vintage\" \"type\" \"temporal\" #> [6] \"spatial\" \"url\" \"modified\" \"description\" \"contact\" dec_apis <- listCensusApis(name = \"dec\", vintage = 2020) dec_apis[, 1:6]"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"dataset-types","dir":"Articles","previous_headings":"Finding your API","what":"Dataset types","title":"Getting started with censusapi","text":"three types datasets included Census Bureau API universe: aggregate, microdata, timeseries. type names defined Census Bureau included column listCensusApis(). users work summary data, either aggregate timeseries. Summary data contains pre-calculated numbers percentages given statistic — like number children state median household income. examples broader list censusapi examples use summary data. Aggregate datasets, like American Community Survey Decennial Census, include data one time period (vintage), usually one year. Datasets like American Community Survey contain thousands pre-computed variables. Timeseries datasets, including Small Area Income Poverty Estimates, Quarterly Workforce Estimates, International Trade statistics, allow users query data time single API call. Microdata contains individual-level responses survey use custom analysis. One row represents one person. advanced analysts want use microdata. Learn microdata use censusapi Accessing microdata.","code":"table(apis$type) #> #> Aggregate Microdata Timeseries #> 624 895 81"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"variable-groups","dir":"Articles","previous_headings":"","what":"Variable groups","title":"Getting started with censusapi","text":"surveys, including American Community Survey Decennial Census, can get many related variables using variable group. groups defined Census Bureau. data tools, like data.census.gov, concept referred table. groups several dozen variables, others just . example, ’ll use American Community Survey get estimate, margin error annotations median household income past 12 months Census places (cities, towns, etc) Alabama using group B19013. First, see descriptions variables group B19013: Now, retrieve data using vars = \"group(B19013)\". alternatively manually list variable vars = c(\"NAME\", \"B19013_001E\", \"B19013_001EA\", \"B19013_001M\", \"B19013_001MA\"), using groups much easier.","code":"group_B19013 <- listCensusMetadata( name = \"acs/acs5\", vintage = 2022, type = \"variables\", group = \"B19013\") group_B19013 acs_income_group <- getCensus( name = \"acs/acs5\", vintage = 2022, vars = \"group(B19013)\", region = \"place:*\", regionin = \"state:01\") head(acs_income_group)"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"advanced-geographies","dir":"Articles","previous_headings":"","what":"Advanced geographies","title":"Getting started with censusapi","text":"geographies, particularly Census tracts blocks, need specified within larger geographies like states counties. varies API endpoint, make sure read documentation specific API run listCensusMetadata(type = \"geographies\") see available options. Tract-level data 2010 Decennial Census can requested one state time. example, use built fips list state FIPS codes request tract-level data state join single data frame. regionin argument getCensus() can also used string nested geographies, shown . 2010 Decennial Census summary file 1 requires specify state county retrieve block-level data. Use region request block level data, regionin specify desired state county. many examples, frequently asked questions, troubleshooting, advanced topics check articles.","code":"tracts <- NULL for (f in fips) { stateget <- paste(\"state:\", f, sep=\"\") temp <- getCensus( name = \"dec/sf1\", vintage = 2010, vars = \"P001001\", region = \"tract:*\", regionin = stateget) tracts <- rbind(tracts, temp) } # How many tracts are present? nrow(tracts) #> [1] 73057 head(tracts) data2010 <- getCensus( name = \"dec/sf1\", vintage = 2010, vars = \"P001001\", region = \"block:*\", regionin = \"state:36+county:027+tract:010000\") head(data2010)"},{"path":"https://www.hrecht.com/censusapi/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Hannah Recht. Author, maintainer.","code":""},{"path":"https://www.hrecht.com/censusapi/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Recht H (2024). censusapi: Retrieve Data Census APIs. R package version 0.9.0.9000, https://github.com/hrecht/censusapi, https://www.hrecht.com/censusapi/.","code":"@Manual{, title = {censusapi: Retrieve Data from the Census APIs}, author = {Hannah Recht}, year = {2024}, note = {R package version 0.9.0.9000, https://github.com/hrecht/censusapi}, url = {https://www.hrecht.com/censusapi/}, }"},{"path":"https://www.hrecht.com/censusapi/index.html","id":"censusapi","dir":"","previous_headings":"","what":"Retrieve Data from the Census APIs","title":"Retrieve Data from the Census APIs","text":"censusapi lightweight package get data U.S. Census Bureau’s APIs. 1,500 API endpoints available, including data surveys Decennial Census, American Community Survey, International Trade Datasets, Small Area Health Insurance Estimates Economics Indicators Time Series. getCensus() lets users retrieves data datasets using simple, consistent syntax. package also includes metadata functions help users determine datasets available variable, geography, options .","code":""},{"path":"https://www.hrecht.com/censusapi/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Retrieve Data from the Census APIs","text":"Get latest stable release CRAN: can also install latest development version censusapi Github using devtools:","code":"install.packages(\"censusapi\") # Install the devtools package if needed # install.packages(\"devtools\") devtools::install_github(\"hrecht/censusapi\")"},{"path":"https://www.hrecht.com/censusapi/index.html","id":"basic-usage","dir":"","previous_headings":"","what":"Basic usage","title":"Retrieve Data from the Census APIs","text":"Using Small Area Income Poverty Estimates dataset, get poverty rate (SAEPOVRTALL_PT) every year since 2010 Los Angeles County, California. Using 2022 5-year American Community Survey Subject Tables dataset, Census tracts Arizona, get : total number households (S2801_C01_001E) number households without internet subscription (S2801_C01_019E) percent households without internet subscription (S2801_C02_019E) Census tract name","code":"poverty_rate <- getCensus( name = \"timeseries/poverty/saipe\", vars = c(\"NAME\", \"SAEPOVRTALL_PT\"), region = \"county:037\", regionin = \"state:06\", time = \"from 2010\") poverty_rate #> time state county NAME SAEPOVRTALL_PT #> 1 2010 06 037 Los Angeles County 17.6 #> 2 2011 06 037 Los Angeles County 18.4 #> 3 2012 06 037 Los Angeles County 19.1 #> 4 2013 06 037 Los Angeles County 19.0 #> 5 2014 06 037 Los Angeles County 18.7 #> 6 2015 06 037 Los Angeles County 16.7 #> 7 2016 06 037 Los Angeles County 16.3 #> 8 2017 06 037 Los Angeles County 14.9 #> 9 2018 06 037 Los Angeles County 14.2 #> 10 2019 06 037 Los Angeles County 13.4 #> 11 2020 06 037 Los Angeles County 13.2 #> 12 2021 06 037 Los Angeles County 14.1 #> 13 2022 06 037 Los Angeles County 13.9 no_internet <- getCensus( name = \"acs/acs5/subject\", vintage = 2022, vars = c(\"S2801_C01_001E\", \"S2801_C01_019E\", \"S2801_C02_019E\", \"NAME\"), region = \"tract:*\", regionin = \"state:04\") head(no_internet) #> state county tract S2801_C01_001E S2801_C01_019E S2801_C02_019E NAME #> 1 04 001 942600 429 412 96.0 Census Tract 9426; Apache County; Arizona #> 2 04 001 942700 1439 1006 69.9 Census Tract 9427; Apache County; Arizona #> 3 04 001 944000 1556 903 58.0 Census Tract 9440; Apache County; Arizona #> 4 04 001 944100 1446 966 66.8 Census Tract 9441; Apache County; Arizona #> 5 04 001 944201 1154 835 72.4 Census Tract 9442.01; Apache County; Arizona #> 6 04 001 944202 1111 874 78.7 Census Tract 9442.02; Apache County; Arizona"},{"path":"https://www.hrecht.com/censusapi/index.html","id":"advanced-usage","dir":"","previous_headings":"","what":"Advanced usage","title":"Retrieve Data from the Census APIs","text":"Users can pass valid parameters APIs using getCensus(). Census Bureau refers filterable parameter variables “predicates”. Using Small Area Health Insurance Estimates, can use predicates get uninsured rate (PCTUI_PT) specific demographic groups, including income group, age group, race/ethnicity. learn using censusapi, read package documentation articles https://www.hrecht.com/censusapi/.","code":"# See the values of `IPRCAT` listCensusMetadata( name = \"timeseries/healthins/sahie\", type = \"values\", variable = \"IPRCAT\") #> code label #> 1 0 All Incomes #> 2 1 Less than or Equal to 200% of Poverty #> 3 2 Less than or Equal to 250% of Poverty #> 4 3 Less than or Equal to 138% of Poverty #> 5 4 Less than or Equal to 400% of Poverty #> 6 5 138% to 400% Poverty # See the values of `AGECAT` listCensusMetadata( name = \"timeseries/healthins/sahie\", type = \"values\", variable = \"AGECAT\") #> code label #> 1 0 Under 65 years #> 2 1 18 to 64 #> 3 2 40 to 64 #> 4 3 50 to 64 #> 5 4 Under 19 years #> 6 5 21 to 64 years # Get the uninsured rate over time for for nonelderly adults (AGECAT = 1) # at 138% to 400% of the federal poverty line (IPRCAT = 5) # in Los Angeles County, California sahie_la <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"PCTUI_PT\"), region = \"county:037\", regionin = \"state:06\", time = \"from 2012\", IPRCAT = 5, AGECAT = 1) sahie_la #> time state county NAME PCTUI_PT IPRCAT AGECAT #> 1 2012 06 037 Los Angeles County, CA 35.5 5 1 #> 2 2013 06 037 Los Angeles County, CA 34.3 5 1 #> 3 2014 06 037 Los Angeles County, CA 25.0 5 1 #> 4 2015 06 037 Los Angeles County, CA 18.6 5 1 #> 5 2016 06 037 Los Angeles County, CA 16.3 5 1 #> 6 2017 06 037 Los Angeles County, CA 15.5 5 1 #> 7 2018 06 037 Los Angeles County, CA 16.2 5 1 #> 8 2019 06 037 Los Angeles County, CA 18.3 5 1 #> 9 2020 06 037 Los Angeles County, CA 16.7 5 1 #> 10 2021 06 037 Los Angeles County, CA 16.1 5 1 # Get the 2021 uninsured rate for nonelderly adults (AGECAT = 1) # at 138% to 400% of the federal poverty line (IPRCAT = 5) # by race and ethnicity for Alabama sahie_alabama <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"PCTUI_PT\", \"RACECAT\", \"RACE_DESC\"), region = \"state:*\", time = 2021, IPRCAT = 5, AGECAT = 1) sahie_alabama #> time state NAME PCTUI_PT RACECAT RACE_DESC IPRCAT AGECAT #> 1 2021 01 Alabama 15.9 0 All Races 5 1 #> 2 2021 01 Alabama 14.1 1 White alone, not Hispanic or Latino 5 1 #> 3 2021 01 Alabama 15.4 2 Black or African American alone, not Hispanic or Latino 5 1 #> 4 2021 01 Alabama 40.4 3 Hispanic or Latino (any race) 5 1 #> 5 2021 01 Alabama 20.8 4 American Indian and Alaska Native alone, not Hispanic or Latino 5 1 #> 6 2021 01 Alabama 14.8 5 Asian alone, not Hispanic or Latino 5 1 #> 7 2021 01 Alabama 20.0 6 Native Hawaiian and Other Pacific Islander alone, not Hispanic or Latino 5 1 #> 8 2021 01 Alabama 16.9 7 Two or More Races, not Hispanic or Latino 5 1"},{"path":"https://www.hrecht.com/censusapi/index.html","id":"disclaimer","dir":"","previous_headings":"","what":"Disclaimer","title":"Retrieve Data from the Census APIs","text":"product uses Census Bureau Data API endorsed certified Census Bureau. Please note project released Contributor Code Conduct. participating project agree abide terms.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/fips.html","id":null,"dir":"Reference","previous_headings":"","what":"List of state fips codes - 50 states plus DC — fips","title":"List of state fips codes - 50 states plus DC — fips","text":"small geographies Census APIs can used state hierarchy. list fips codes may looped retrieve data states.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/fips.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"List of state fips codes - 50 states plus DC — fips","text":"","code":"fips"},{"path":"https://www.hrecht.com/censusapi/reference/fips.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"List of state fips codes - 50 states plus DC — fips","text":"list fips codes 50 states District Columbia.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/fips.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"List of state fips codes - 50 states plus DC — fips","text":"","code":"fips #> [1] \"01\" \"02\" \"04\" \"05\" \"06\" \"08\" \"09\" \"10\" \"11\" \"12\" \"13\" \"15\" \"16\" \"17\" \"18\" #> [16] \"19\" \"20\" \"21\" \"22\" \"23\" \"24\" \"25\" \"26\" \"27\" \"28\" \"29\" \"30\" \"31\" \"32\" \"33\" #> [31] \"34\" \"35\" \"36\" \"37\" \"38\" \"39\" \"40\" \"41\" \"42\" \"44\" \"45\" \"46\" \"47\" \"48\" \"49\" #> [46] \"50\" \"51\" \"53\" \"54\" \"55\" \"56\""},{"path":"https://www.hrecht.com/censusapi/reference/getCensus.html","id":null,"dir":"Reference","previous_headings":"","what":"Retrieve Census data from a given API — getCensus","title":"Retrieve Census data from a given API — getCensus","text":"Retrieve Census data given API","code":""},{"path":"https://www.hrecht.com/censusapi/reference/getCensus.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Retrieve Census data from a given API — getCensus","text":"","code":"getCensus( name, vintage = NULL, key = NULL, vars, region = NULL, regionin = NULL, time = NULL, show_call = FALSE, convert_variables = TRUE, year = NULL, date = NULL, period = NULL, monthly = NULL, category_code = NULL, data_type_code = NULL, naics = NULL, pscode = NULL, naics2012 = NULL, naics2007 = NULL, naics2002 = NULL, naics1997 = NULL, sic = NULL, ... )"},{"path":"https://www.hrecht.com/censusapi/reference/getCensus.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Retrieve Census data from a given API — getCensus","text":"name programmatic name dataset, e.g. \"timeseries/poverty/saipe\" \"acs/acs5\". Use listCensusApis() see valid dataset names. Required. vintage Vintage (year) dataset, e.g. 2014. required timeseries APIs. key Census API key, obtained https://api.census.gov/data/key_signup.html. CENSUS_KEY CENSUS_API_KEY stored .Renviron file, getCensus() automatically use key. Using key recommended required. vars List variables get. Required. region Geography get. regionin Optional hierarchical geography limit region. time Time period data get. Required timeseries APIs. show_call Display underlying API call sent Census Bureau. Default FALSE. convert_variables Convert columns likely numbers numeric data. Default TRUE. false, columns characters, type returned Census Bureau. year, date, period, monthly, category_code, data_type_code, naics, pscode, naics2012, naics2007, naics2002, naics1997, sic Optional arguments used timeseries data APIs. ... valid arguments pass Census API. Note: APIs case sensitive.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/getCensus.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Retrieve Census data from a given API — getCensus","text":"data frame results specified U.S. Census Bureau dataset.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/getCensus.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Retrieve Census data from a given API — getCensus","text":"","code":"# Get total population and median household income for Census places # (cities, towns, villages) in a single state from the 5-year American Community Survey. acs_simple <- getCensus( name = \"acs/acs5\", vintage = 2022, vars = c(\"NAME\", \"B01001_001E\", \"B19013_001E\"), region = \"place:*\", regionin = \"state:01\") head(acs_simple) #> state place NAME B01001_001E B19013_001E #> 1 01 00100 Abanda CDP, Alabama 335 29263 #> 2 01 00124 Abbeville city, Alabama 2309 35147 #> 3 01 00460 Adamsville city, Alabama 4325 58631 #> 4 01 00484 Addison town, Alabama 665 47188 #> 5 01 00676 Akron town, Alabama 310 53929 #> 6 01 00820 Alabaster city, Alabama 33417 89423 # Get all data from the B08301 variable group, \"Means of Transportation to Work.\" # This returns estimates as well as margins of error and annotation flags. acs_group <- getCensus( name = \"acs/acs5\", vintage = 2022, vars = \"group(B08301)\", region = \"state:*\") head(acs_group) #> state B08301_001E B08301_001EA B08301_001M B08301_001MA B08301_002E #> 1 01 2183677 9550 1985736 #> 2 02 351067 2187 274263 #> 3 04 3244419 9451 2610395 #> 4 05 1304084 6929 1177402 #> 5 06 18353469 22043 14313290 #> 6 08 3006848 8149 2304559 #> B08301_002EA B08301_002M B08301_002MA B08301_003E B08301_003EA B08301_003M #> 1 10017 1808631 9646 #> 2 2820 231484 3143 #> 3 12006 2285920 12162 #> 4 6616 1051964 6428 #> 5 23546 12561068 25223 #> 6 9026 2062480 8986 #> B08301_003MA B08301_004E B08301_004EA B08301_004M B08301_004MA B08301_005E #> 1 177105 4751 137578 #> 2 42779 2105 32397 #> 3 324475 5200 242556 #> 4 125438 3531 94684 #> 5 1752222 14058 1269237 #> 6 242079 5338 180493 #> B08301_005EA B08301_005M B08301_005MA B08301_006E B08301_006EA B08301_006M #> 1 4204 24358 1675 #> 2 1886 5712 684 #> 3 4612 48889 1844 #> 4 2975 18415 1284 #> 5 10568 281935 5811 #> 6 4522 37353 1984 #> B08301_006MA B08301_007E B08301_007EA B08301_007M B08301_007MA B08301_008E #> 1 8791 1005 2998 #> 2 2977 646 1039 #> 3 18286 1327 10171 #> 4 7226 913 2976 #> 5 109445 3668 61640 #> 6 14757 1317 6621 #> B08301_008EA B08301_008M B08301_008MA B08301_009E B08301_009EA B08301_009M #> 1 551 3380 602 #> 2 255 654 256 #> 3 1062 4573 689 #> 4 636 2137 354 #> 5 2554 29965 1345 #> 6 758 2855 496 #> B08301_009MA B08301_010E B08301_010EA B08301_010M B08301_010MA B08301_011E #> 1 6982 910 6523 #> 2 3805 603 3415 #> 3 40113 2078 35607 #> 4 3744 551 3387 #> 5 662772 7190 423288 #> 6 63953 2586 45745 #> B08301_011EA B08301_011M B08301_011MA B08301_012E B08301_012EA B08301_012M #> 1 928 122 117 #> 2 577 1 3 #> 3 1989 960 238 #> 4 494 114 97 #> 5 5639 140862 3435 #> 6 2229 4035 418 #> B08301_012MA B08301_013E B08301_013EA B08301_013M B08301_013MA B08301_014E #> 1 77 55 73 #> 2 15 23 14 #> 3 471 198 2692 #> 4 2 5 59 #> 5 58487 2233 28260 #> 6 2546 416 11234 #> B08301_014EA B08301_014M B08301_014MA B08301_015E B08301_015EA B08301_015M #> 1 95 187 100 #> 2 15 360 176 #> 3 455 383 143 #> 4 51 182 170 #> 5 1506 11875 985 #> 6 864 393 164 #> B08301_015MA B08301_016E B08301_016EA B08301_016M B08301_016MA B08301_017E #> 1 1253 321 1878 #> 2 1599 368 474 #> 3 6508 836 10036 #> 4 603 202 1278 #> 5 37588 1610 46193 #> 6 2955 510 4587 #> B08301_017EA B08301_017M B08301_017MA B08301_018E B08301_018EA B08301_018M #> 1 307 1805 302 #> 2 127 2447 414 #> 3 824 19629 1240 #> 4 269 2052 380 #> 5 1803 135240 3079 #> 6 503 30681 1435 #> B08301_018MA B08301_019E B08301_019EA B08301_019M B08301_019MA B08301_020E #> 1 24058 1737 16559 #> 2 27039 1177 13159 #> 3 54751 2254 40263 #> 4 19571 1110 11443 #> 5 437430 5563 220114 #> 6 79574 2429 24630 #> B08301_020EA B08301_020M B08301_020MA B08301_021E B08301_021EA B08301_021M #> 1 1341 145406 4523 #> 2 672 28281 1635 #> 3 2081 462724 7442 #> 4 1050 87991 2781 #> 5 4380 2500842 15830 #> 6 1187 495909 6033 #> B08301_021MA GEO_ID NAME #> 1 0400000US01 Alabama #> 2 0400000US02 Alaska #> 3 0400000US04 Arizona #> 4 0400000US05 Arkansas #> 5 0400000US06 California #> 6 0400000US08 Colorado # Retreive 2020 Decennial Census block group data within a specific Census tract, # using the regionin argument to precisely specify the Census tract, county, # and state. decennial_block_group <- getCensus( name = \"dec/dhc\", vintage = 2020, vars = c(\"NAME\", \"P1_001N\"), region = \"block group:*\", regionin = \"state:36+county:027+tract:220300\") head(decennial_block_group) #> state county tract block_group #> 1 36 027 220300 1 #> 2 36 027 220300 2 #> 3 36 027 220300 3 #> 4 36 027 220300 4 #> NAME P1_001N #> 1 Block Group 1; Census Tract 2203; Dutchess County; New York 1467 #> 2 Block Group 2; Census Tract 2203; Dutchess County; New York 1394 #> 3 Block Group 3; Census Tract 2203; Dutchess County; New York 1192 #> 4 Block Group 4; Census Tract 2203; Dutchess County; New York 885 # Get poverty rates for children and for people of all ages beginning in 2000 using the # Small Area Income and Poverty Estimates API saipe <- getCensus( name = \"timeseries/poverty/saipe\", vars = c(\"NAME\", \"SAEPOVRT0_17_PT\", \"SAEPOVRTALL_PT\"), region = \"state:01\", time = \"from 2000\") head(saipe) #> time state NAME SAEPOVRT0_17_PT SAEPOVRTALL_PT #> 1 2000 01 Alabama 20.5 14.6 #> 2 2001 01 Alabama 22.1 15.7 #> 3 2002 01 Alabama 21.6 15.4 #> 4 2003 01 Alabama 22.3 15.3 #> 5 2004 01 Alabama 22.6 16.1 #> 6 2005 01 Alabama 24.3 16.9 # Get the number of employees and number of establishments in the construction sector, # NAICS2017 code 23, using the County Business Patterns API cbp <- getCensus( name = \"cbp\", vintage = 2021, vars = c(\"EMP\", \"ESTAB\", \"NAICS2017_LABEL\"), region = \"county:*\", NAICS2017 = 23) head(cbp) #> state county EMP ESTAB NAICS2017_LABEL NAICS2017 #> 1 01 001 507 90 Construction 23 #> 2 01 003 4322 705 Construction 23 #> 3 01 005 75 20 Construction 23 #> 4 01 007 654 25 Construction 23 #> 5 01 009 592 118 Construction 23 #> 6 01 011 50 8 Construction 23"},{"path":"https://www.hrecht.com/censusapi/reference/getFunction.html","id":null,"dir":"Reference","previous_headings":"","what":"Internal function: Get the API response, return a data frame — getFunction","title":"Internal function: Get the API response, return a data frame — getFunction","text":"Internal function: Get API response, return data frame","code":""},{"path":"https://www.hrecht.com/censusapi/reference/getFunction.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Internal function: Get the API response, return a data frame — getFunction","text":"","code":"getFunction( apiurl, name, key, get, region, regionin, time, show_call, convert_variables, year, date, period, monthly, category_code, data_type_code, naics, pscode, naics2012, naics2007, naics2002, naics1997, sic, ... )"},{"path":"https://www.hrecht.com/censusapi/reference/get_api_key.html","id":null,"dir":"Reference","previous_headings":"","what":"Retrieve a Census API key stored the .Renivron file — get_api_key","title":"Retrieve a Census API key stored the .Renivron file — get_api_key","text":"Retrieve Census API key stored .Renivron file","code":""},{"path":"https://www.hrecht.com/censusapi/reference/get_api_key.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Retrieve a Census API key stored the .Renivron file — get_api_key","text":"","code":"get_api_key()"},{"path":"https://www.hrecht.com/censusapi/reference/get_api_key.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Retrieve a Census API key stored the .Renivron file — get_api_key","text":"CENSUS_KEY CENSUS_API_KEY string stored user's .Renviron. file, warning message printed per R session none found.","code":""},{"path":[]},{"path":"https://www.hrecht.com/censusapi/reference/get_api_key.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Retrieve a Census API key stored the .Renivron file — get_api_key","text":"","code":"if (FALSE) { get_api_key() }"},{"path":"https://www.hrecht.com/censusapi/reference/has_api_key.html","id":null,"dir":"Reference","previous_headings":"","what":"Is there a saved API token? — has_api_key","title":"Is there a saved API token? — has_api_key","text":"saved API token?","code":""},{"path":"https://www.hrecht.com/censusapi/reference/has_api_key.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is there a saved API token? — has_api_key","text":"","code":"has_api_key()"},{"path":[]},{"path":"https://www.hrecht.com/censusapi/reference/has_api_key.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is there a saved API token? — has_api_key","text":"","code":"has_api_key() #> [1] TRUE"},{"path":"https://www.hrecht.com/censusapi/reference/listCensusApis.html","id":null,"dir":"Reference","previous_headings":"","what":"Get general information about available datasets — listCensusApis","title":"Get general information about available datasets — listCensusApis","text":"Scrapes https://api.census.gov/data.json returns dataframe includes columns dataset title, description, name, vintage, url, dataset type, useful fields.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/listCensusApis.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get general information about available datasets — listCensusApis","text":"","code":"listCensusApis(name = NULL, vintage = NULL)"},{"path":"https://www.hrecht.com/censusapi/reference/listCensusApis.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get general information about available datasets — listCensusApis","text":"name Optional complete partial API dataset programmatic name. example, \"acs\", \"acs/acs5\", \"acs/acs5/subject\". using partial name, needs left-part dataset name /, e.g. \"timeseries/eits\" \"dec\" \"acs/acs5\". vintage Optional vintage (year) dataset.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/listCensusApis.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get general information about available datasets — listCensusApis","text":"data frame following columns: title: Short written description dataset. name: Programmatic name dataset. vintage: Year survey, use microdata aggregate datasets. type: Dataset type, either \"Aggregate\", \"Microdata\", \"Timeseries\". temporal: Time period dataset. Warning: always documented. spatial: Spatial region dataset. Warning: always documented. url: Base URL dataset endpoint. modified: Date last modified. Warning: sometimes date. description: Long written description dataset. contact: Email address specific questions Census Bureau survey.","code":""},{"path":[]},{"path":"https://www.hrecht.com/censusapi/reference/listCensusApis.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get general information about available datasets — listCensusApis","text":"","code":"# Get information about every dataset available in the APIs apis <- listCensusApis() head(apis) #> title name #> 1 Current Population Survey: Basic Monthly cps/basic/feb #> 2 Current Population Survey: Basic Monthly cps/basic/jan #> 3 Current Population Survey Annual Social and Economic Supplement cps/asec/mar #> 4 Current Population Survey: Basic Monthly cps/basic/apr #> 5 Current Population Survey: Basic Monthly cps/basic/aug #> 6 Current Population Survey: Basic Monthly cps/basic/dec #> vintage type temporal spatial #> 1 2024 Microdata 2024-02/2024-02 United States #> 2 2024 Microdata 2024-01/2024-01 United States #> 3 2023 Microdata 2023-03/2023-03 United States #> 4 2023 Microdata 2023-04/2023-04 United States #> 5 2023 Microdata 2023-08/2023-08 United States #> 6 2023 Microdata 2023-12/2023-12 United States #> url modified #> 1 http://api.census.gov/data/2024/cps/basic/feb 2024-01-11 15:35:41.0 #> 2 http://api.census.gov/data/2024/cps/basic/jan 2024-01-11 15:35:41.0 #> 3 http://api.census.gov/data/2023/cps/asec/mar 2023-08-14 09:09:01.0 #> 4 http://api.census.gov/data/2023/cps/basic/apr 2023-01-10 15:11:40.0 #> 5 http://api.census.gov/data/2023/cps/basic/aug 2023-01-10 15:11:40.0 #> 6 http://api.census.gov/data/2023/cps/basic/dec 2023-01-10 15:11:40.0 #> description #> 1 To provide estimates of employment, unemployment, and other characteristics of the general labor force, of the population as a whole, and of various subgroups of the population. Monthly labor force data for the country are used by the Bureau of Labor Statistics (BLS) to determine the distribution of funds under the Job Training Partnership Act. These data are collected through combined computer-assisted personal interviewing (CAPI) and computer-assisted telephone interviewing (CATI). In addition to the labor force data, the CPS basic funding provides annual data on work experience, income, health insurance, and migration data from the Annual Social and Economic Supplement (ASEC), and on school enrollment of the population from the October Supplement. Other supplements, some of which are sponsored by other agencies, are conducted biennially or intermittently. #> 2 To provide estimates of employment, unemployment, and other characteristics of the general labor force, of the population as a whole, and of various subgroups of the population. Monthly labor force data for the country are used by the Bureau of Labor Statistics (BLS) to determine the distribution of funds under the Job Training Partnership Act. These data are collected through combined computer-assisted personal interviewing (CAPI) and computer-assisted telephone interviewing (CATI). In addition to the labor force data, the CPS basic funding provides annual data on work experience, income, health insurance, and migration data from the Annual Social and Economic Supplement (ASEC), and on school enrollment of the population from the October Supplement. Other supplements, some of which are sponsored by other agencies, are conducted biennially or intermittently. #> 3 The Annual Social and Economic Supplement or March CPS supplement is the primary source of detailed information on income and work experience in the United States. Numerous publications based on this survey are issued each year by the Bureaus of Labor Statistics and Census. A public-use microdata file is available for private researchers, who also produce many academic and policy-related documents based on these data. The Annual Social and Economic Supplement is used to generate the annual Population Profile of the United States, reports on geographical mobility and educational attainment, and detailed analysis of money income and poverty status. The labor force and work experience data from this survey are used to profile the U.S. labor market and to make employment projections. To allow for the same type of in-depth analysis of hispanics, additional hispanic sample units are added to the basic CPS sample in March each year. Additional weighting is also performed so that estimates can be made for households and families, in addition to persons. #> 4 To provide estimates of employment, unemployment, and other characteristics of the general labor force, of the population as a whole, and of various subgroups of the population. Monthly labor force data for the country are used by the Bureau of Labor Statistics (BLS to determine the distribution of funds under the Job Training Partnership Act. These data are collected through combined computer-assisted personal interviewing (CAPI) and computer-assisted telephone interviewing (CATI). In addition to the labor force data, the CPS basic funding provides annual data on work experience, income, health insurance, and migration data from the Annual Social and Economic Supplement (ASEC), and on school enrollment of the population from the October Supplement. Other supplements, some of which are sponsored by other agencies, are conducted biennially or intermittently. #> 5 To provide estimates of employment, unemployment, and other characteristics of the general labor force, of the population as a whole, and of various subgroups of the population. Monthly labor force data for the country are used by the Bureau of Labor Statistics (BLS to determine the distribution of funds under the Job Training Partnership Act. These data are collected through combined computer-assisted personal interviewing (CAPI) and computer-assisted telephone interviewing (CATI). In addition to the labor force data, the CPS basic funding provides annual data on work experience, income, health insurance, and migration data from the Annual Social and Economic Supplement (ASEC), and on school enrollment of the population from the October Supplement. Other supplements, some of which are sponsored by other agencies, are conducted biennially or intermittently. #> 6 To provide estimates of employment, unemployment, and other characteristics of the general labor force, of the population as a whole, and of various subgroups of the population. Monthly labor force data for the country are used by the Bureau of Labor Statistics (BLS) to determine the distribution of funds under the Job Training Partnership Act. These data are collected through combined computer-assisted personal interviewing (CAPI) and computer-assisted telephone interviewing (CATI). In addition to the labor force data, the CPS basic funding provides annual data on work experience, income, health insurance, and migration data from the Annual Social and Economic Supplement (ASEC), and on school enrollment of the population from the October Supplement. Other supplements, some of which are sponsored by other agencies, are conducted biennially or intermittently. #> contact #> 1 dsd.cps@census.gov #> 2 dsd.cps@census.gov #> 3 dsd.cps@census.gov #> 4 dsd.cps@census.gov #> 5 dsd.cps@census.gov #> 6 dsd.cps@census.gov # Get information about all vintage 2022 datasets apis_2022 <- listCensusApis(vintage = 2022) head(apis_2022) #> title #> 1 American Community Survey: 1-Year Estimates: Detailed Tables 1-Year #> 2 American Community Survey: 1-Year Estimates: Comparison Profiles 1-Year #> 3 American Community Survey: 1-Year Estimates: Data Profiles 1-Year #> 4 2022 American Community Survey: 1-Year Estimates - Public Use Microdata Sample #> 5 2022 American Community Survey: 1-Year Estimates - Public Use Microdata Sample Puerto Rico #> 6 American Community Survey: 1-Year Estimates: Selected Population Profiles 1-Year #> name vintage type temporal spatial #> 1 acs/acs1 2022 Aggregate 2022/2022 US #> 2 acs/acs1/cprofile 2022 Aggregate 2022/2022 US #> 3 acs/acs1/profile 2022 Aggregate 2022/2022 US #> 4 acs/acs1/pums 2022 Microdata 2022/2022 US #> 5 acs/acs1/pumspr 2022 Microdata 2022/2022 Puerto Rico #> 6 acs/acs1/spp 2022 Aggregate 2022/2022 US #> url modified #> 1 http://api.census.gov/data/2022/acs/acs1 2023-04-24 14:51:53.0 #> 2 http://api.census.gov/data/2022/acs/acs1/cprofile 2023-04-24 14:49:08.0 #> 3 http://api.census.gov/data/2022/acs/acs1/profile 2023-04-24 14:49:41.0 #> 4 http://api.census.gov/data/2022/acs/acs1/pums 2023-06-08 10:03:42.0 #> 5 http://api.census.gov/data/2022/acs/acs1/pumspr 2023-06-08 10:03:09.0 #> 6 http://api.census.gov/data/2022/acs/acs1/spp 2023-04-24 14:51:20.0 #> description #> 1 The American Community Survey (ACS) is an ongoing survey that provides data every year -- giving communities the current information they need to plan investments and services. The ACS covers a broad range of topics about social, economic, demographic, and housing characteristics of the U.S. population. Much of the ACS data provided on the Census Bureau's Web site are available separately by age group, race, Hispanic origin, and sex. Summary files, Subject tables, Data profiles, and Comparison profiles are available for the nation, all 50 states, the District of Columbia, Puerto Rico, every congressional district, every metropolitan area, and all counties and places with populations of 65,000 or more. Detailed Tables contain the most detailed cross-tabulations published for areas 65k and more. The data are population counts. There are over 31,000 variables in this dataset. #> 2 The American Community Survey (ACS) is an ongoing survey that provides data every year -- giving communities the current information they need to plan investments and services. The ACS covers a broad range of topics about social, economic, demographic, and housing characteristics of the U.S. population. Much of the ACS data provided on the Census Bureau's Web site are available separately by age group, race, Hispanic origin, and sex. Summary files, Subject tables, Data profiles, and Comparison profiles are available for the nation, all 50 states, the District of Columbia, Puerto Rico, every congressional district, every metropolitan area, and all counties and places with populations of 65,000 or more. Comparison profiles are similar to Data profiles but also include comparisons with past-year data. The current year data are compared with each of the last four years of data and include statistical significance testing. There are over 1,000 variables in this dataset. #> 3 The American Community Survey (ACS) is a US-wide survey designed to provide communities a fresh look at how they are changing. The ACS replaced the decennial census long form in 2010 and thereafter by collecting long form type information throughout the decade rather than only once every 10 years. Questionnaires are mailed to a sample of addresses to obtain information about households -- that is, about each person and the housing unit itself. The American Community Survey produces demographic, social, housing and economic estimates in the form of 1 and 5-year estimates based on population thresholds. The strength of the ACS is in estimating population and housing characteristics. The data profiles provide key estimates for each of the topic areas covered by the ACS for the us, all 50 states, the District of Columbia, Puerto Rico, every congressional district, every metropolitan area, and all counties and places with populations of 65,000 or more. Although the ACS produces population, demographic and housing unit estimates, it is the Census Bureau's Population Estimates Program that produces and disseminates the official estimates of the population for the US, states, counties, cities and towns, and estimates of housing units for states and counties. For 2010 and other decennial census years, the Decennial Census provides the official counts of population and housing units. #> 4 The American Community Survey (ACS) Public Use Microdata Sample (PUMS) contains a sample of responses to the ACS. The ACS PUMS dataset includes variables for nearly every question on the survey, as well as many new variables that were derived after the fact from multiple survey responses (such as poverty status). Each record in the file represents a single person, or, in the household-level dataset, a single housing unit. In the person-level file, individuals are organized into households, making possible the study of people within the contexts of their families and other household members. Individuals living in Group Quarters, such as nursing facilities or college facilities, are also included on the person file. ACS PUMS data are available at the nation, state, and Public Use Microdata Area (PUMA) levels. PUMAs are special non-overlapping areas that partition each state into contiguous geographic units containing roughly 100,000 people each. ACS PUMS files for an individual year, such as 2022, contain data on approximately one percent of the United States population. #> 5 The Public Use Microdata Sample (PUMS) for Puerto Rico (PR) contains a sample of responses to the Puerto Rico Community Survey (PRCS). The PRCS is similar to, but separate from, the American Community Survey (ACS). The PRCS collects data about the population and housing units in Puerto Rico. Puerto Rico data is not included in the national PUMS files. It is published as a state equivalent file and has a State FIPS code of \"72\". The file includes variables for nearly every question on the survey, as well as many new variables that were derived after the fact from multiple survey responses (such as poverty status). Each record in the file represents a single person, or, in the household-level dataset, a single housing unit. In the person-level file, individuals are organized into households, making possible the study of people within the contexts of their families and other household members. Individuals living in Group Quarters, such as nursing facilities or college facilities, are also included on the person file. Data are available at the state and Public Use Microdata Area (PUMA) levels. PUMAs are special non-overlapping areas that partition Puerto Rico into contiguous geographic units containing roughly 100,000 people each. The Puerto Rico PUMS file for an individual year, such as 2022, contain data on approximately one percent of the Puerto Rico population. #> 6 Selected Population Profiles provide broad social, economic, and housing profiles for a large number of race, ethnic, ancestry, and country/region of birth groups. The data are presented as population counts for the total population and various subgroups and percentages. #> contact #> 1 acso.users.support@census.gov #> 2 acso.users.support@census.gov #> 3 acso.users.support@census.gov #> 4 acso.users.support@census.gov #> 5 acso.users.support@census.gov #> 6 acso.users.support@census.gov # Get information about all timeseries datasets apis_timeseries <- listCensusApis(name = \"timeseries\") head(apis_timeseries) #> title #> 1 Annual Economic Surveys: Annual Survey of Manufactures Area #> 2 Economic Surveys: Annual Survey of Manufactures: Annual Survey of Manufactures Area #> 3 Annual Economic Surveys: Annual Survey of Manufactures Benchmark 2017 #> 4 Time Series Annual Survey of Manufactures: Statistics for Industry Groups and Industries #> 5 Time Series Annual Survey of Manufactures: Value of Shipments for Product Classes #> 6 Time Series Annual Survey of Manufactures: Statistics for All Manufacturing by State #> name type temporal spatial #> 1 timeseries/asm/area2012 Timeseries #> 2 timeseries/asm/area2017 Timeseries 2018/2021 United States #> 3 timeseries/asm/benchmark2017 Timeseries #> 4 timeseries/asm/industry Timeseries United States #> 5 timeseries/asm/product Timeseries United States #> 6 timeseries/asm/state Timeseries United States #> url modified #> 1 http://api.census.gov/data/timeseries/asm/area2012 2018-12-13 00:00:00.0 #> 2 http://api.census.gov/data/timeseries/asm/area2017 2020-03-17 00:00:00.0 #> 3 http://api.census.gov/data/timeseries/asm/benchmark2017 2021-03-17 00:00:00.0 #> 4 http://api.census.gov/data/timeseries/asm/industry 2018-06-29 #> 5 http://api.census.gov/data/timeseries/asm/product 2017-12-15 #> 6 http://api.census.gov/data/timeseries/asm/state 2017-12-15 #> description #> 1 The Annual Survey of Manufactures (ASM) provides key intercensal measures of manufacturing activity, products, and location for the public and private sectors. The ASM provides the best current measure of current U.S. manufacturing industry outputs, inputs, and operating status, and is the primary basis for updates of the Longitudinal Research Database (LRD). Census Bureau staff and academic researchers with sworn agent status use the LRD for micro data analysis. #> 2 The Annual Survey of Manufactures (ASM) provides key intercensal measures of manufacturing activity, products, and location for the public and private sectors. The ASM provides the best current measure of current U.S. manufacturing industry outputs, inputs, and operating status, and is the primary basis for updates of the Longitudinal Research Database (LRD). Census Bureau staff and academic researchers with sworn agent status use the LRD for micro data analysis. #> 3 The Annual Survey of Manufactures (ASM) Benchmark provides key intercensal measures of manufacturing activity and products for the public and private sectors for four years following the Economic Census of Manufacturing. These benchmark tables present manufacturing establishment statistics from the 2013-2016 Annual Survey of Manufactures (ASM). The ASM Benchmark provides statistics on employment, payroll, worker hours, cost of materials, value added by manufacturing, inventories, and estimates for value of shipments for product classes of products manufactured as defined by the North American Industry Classification System. The ASM provides the best current measure of current U.S. manufacturing industry outputs, inputs, and operating status, and is the primary basis for updates of the Longitudinal Research Database (LRD). Census Bureau staff and academic researchers with sworn agent status use the LRD for micro data analysis. #> 4 The Annual Survey of Manufactures (ASM) provides key intercensal measures of manufacturing activity, products, and location for the public and private sectors. The ASM provides the best current measure of current U.S. manufacturing industry outputs, inputs, and operating status, and is the primary basis for updates of the Longitudinal Research Database (LRD). Census Bureau staff and academic researchers with sworn agent status use the LRD for micro data analysis. #> 5 The Annual Survey of Manufactures (ASM) provides key intercensal measures of manufacturing activity, products, and location for the public and private sectors. The ASM provides the best current measure of current U.S. manufacturing industry outputs, inputs, and operating status, and is the primary basis for updates of the Longitudinal Research Database (LRD). Census Bureau staff and academic researchers with sworn agent status use the LRD for micro data analysis. #> 6 The Annual Survey of Manufactures (ASM) provides key intercensal measures of manufacturing activity, products, and location for the public and private sectors. The ASM provides the best current measure of current U.S. manufacturing industry outputs, inputs, and operating status, and is the primary basis for updates of the Longitudinal Research Database (LRD). Census Bureau staff and academic researchers with sworn agent status use the LRD for micro data analysis. #> contact #> 1 Ewd.outreach@census.gov #> 2 ewd.outreach@census.gov #> 3 Ewd.outreach@census.gov #> 4 econ.dissemination@census.gov #> 5 stephen.c.mangum@census.gov #> 6 stephen.c.mangum@census.gov # Get information about 2020 Decennial Census datasets apis_decennial_2020 <- listCensusApis(name = \"dec\", vintage = 2020) head(apis_decennial_2020) #> title #> 1 Decennial Census: 118th Congressional District Summary File #> 2 Decennial Census of Island Areas: American Samoa Detailed Crosstabulations #> 3 Decennial Census of Island Areas: Guam Detailed Crosstabulations #> 4 Decennial Census of Island Areas: Commonwealth of the Northern Mariana Islands Detailed Crosstabulations #> 5 Decennial Census of Island Areas: U.S. Virgin Islands Detailed Crosstabulations #> 6 Decennial Census: Detailed Demographic and Housing Characteristics File A #> name vintage type temporal spatial #> 1 dec/cd118 2020 Aggregate 2020/2020 US #> 2 dec/crosstabas 2020 Aggregate 2020/2020 American Samoa #> 3 dec/crosstabgu 2020 Aggregate 2020/2020 Guam #> 4 dec/crosstabmp 2020 Aggregate 2020/2020 Northern Mariana Islands #> 5 dec/crosstabvi 2020 Aggregate 2020/2020 U.S. Virgin Islands #> 6 dec/ddhca 2020 Aggregate 2020/2020 United States #> url modified #> 1 http://api.census.gov/data/2020/dec/cd118 2022-10-25 00:00:00.0 #> 2 http://api.census.gov/data/2020/dec/crosstabas 2023-05-09 10:44:24.0 #> 3 http://api.census.gov/data/2020/dec/crosstabgu 2023-05-09 10:46:02.0 #> 4 http://api.census.gov/data/2020/dec/crosstabmp 2023-05-09 10:45:29.0 #> 5 http://api.census.gov/data/2020/dec/crosstabvi 2023-05-09 10:44:57.0 #> 6 http://api.census.gov/data/2020/dec/ddhca 2022-09-09 00:00:00.0 #> description #> 1 The Congressional District Summary File (118th Congress) (CD118) contains the data compiled from the questions asked of all people and about every housing unit in the 2020 Census. This product retabulates selected summary levels from the Demographic and Housing Characteristics File (DHC) for the 118th Congress and 2022 state legislative districts. Population items include age, sex, race, Hispanic or Latino origin, household type, family type, relationship to householder, group quarters population, housing occupancy and housing tenure (whether a housing unit is owner-occupied or renter-occupied). #> 2 This product will include key socio-demographic and economic variables presented in cross-tabulations that present the complex data together. #> 3 This product will include…. #> 4 This product will include key socio-demographic and economic variables presented in cross-tabulations that present the complex data together. #> 5 This product will include key socio-demographic and economic variables presented in cross-tabulations that present the complex data together. #> 6 This product provides the population counts and sex and age statistics for detailed racial and ethnic groups and American Indian and Alaska Native tribes and villages. #> contact #> 1 pio@census.gov #> 2 pio@census.gov #> 3 pio@census.gov #> 4 pio@census.gov #> 5 pio@census.gov #> 6 pio@census.gov # Get information about one particular dataset api_sahie <- listCensusApis(name = \"timeseries/healthins/sahie\") head(api_sahie) #> title #> 1 Small Area Health Insurance Estimates: Small Area Health Insurance Estimates #> name type temporal spatial #> 1 timeseries/healthins/sahie Timeseries 2006/2020 US #> url modified #> 1 http://api.census.gov/data/timeseries/healthins/sahie 2021-04-12 00:00:00.0 #> description #> 1 The U.S. Census Bureau's Small Area Health Insurance Estimates program produces the only source of data for single-year estimates of health insurance coverage status for all counties in the U.S. by selected economic and demographic characteristics. This program is partially funded by the Centers for Disease Control and Prevention's (CDC) Division of Cancer Prevention and Control (DCPC). The CDC have a congressional mandate to provide screening services for breast and cervical cancer to low-income, uninsured, and underserved women through the National Breast and Cervical Cancer Early Detection Program (NBCCEDP). For estimation, SAHIE uses statistical models that combine survey data from the American Community Survey (ACS) with administrative records data and Census 2010 data. #> contact #> 1 Sehsd.sahie@census.gov"},{"path":"https://www.hrecht.com/censusapi/reference/listCensusMetadata.html","id":null,"dir":"Reference","previous_headings":"","what":"Get metadata about a specified API endpoint — listCensusMetadata","title":"Get metadata about a specified API endpoint — listCensusMetadata","text":"Get information Census Bureau API dataset, including available variables, geographies, variable groups, value labels","code":""},{"path":"https://www.hrecht.com/censusapi/reference/listCensusMetadata.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get metadata about a specified API endpoint — listCensusMetadata","text":"","code":"listCensusMetadata( name, vintage = NULL, type = \"variables\", group = NULL, variable_name = NULL, include_values = FALSE )"},{"path":"https://www.hrecht.com/censusapi/reference/listCensusMetadata.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get metadata about a specified API endpoint — listCensusMetadata","text":"name API programmatic name - e.g. acs/acs5. Use listCensusApis() see valid dataset names. vintage Vintage (year) dataset. required timeseries APIs. type Type metadata return. Options : \"variables\" (default) - list variable names descriptions dataset. \"geographies\" - available geographies. \"groups\" - available variable groups. available datasets. \"values\" - encoded value labels given variable. Pair \"variable_name\". available datasets. group optional variable group code, used return metadata specific group variables . Variable groups used APIs. variable_name name specific variable used return value labels variable. Value labels used APIs. include_values Use type = \"variables\". Include value metadata variables dataset value metadata exists. Default \"FALSE\".","code":""},{"path":"https://www.hrecht.com/censusapi/reference/listCensusMetadata.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get metadata about a specified API endpoint — listCensusMetadata","text":"data frame metadata specified API endpoint.","code":""},{"path":[]},{"path":"https://www.hrecht.com/censusapi/reference/listCensusMetadata.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get metadata about a specified API endpoint — listCensusMetadata","text":"","code":"# type: variables # List the variables available in the Small Area # Health Insurance Estimates. variables <- listCensusMetadata( name = \"timeseries/healthins/sahie\", type = \"variables\") head(variables) #> name #> 1 for #> 2 in #> 3 time #> 4 NIPR_LB90 #> 5 NIPR_PT #> 6 AGECAT #> label #> 1 Census API FIPS 'for' clause #> 2 Census API FIPS 'in' clause #> 3 ISO-8601 Date/Time value #> 4 Number in Demographic Group for Selected Income Range, Upper Bound for 90% Confidence Interval #> 5 Number in Demographic Group for Selected Income Range, Estimate #> 6 Age Category #> concept predicateType group limit predicateOnly #> 1 Census API Geography Specification fips-for N/A 0 TRUE #> 2 Census API Geography Specification fips-in N/A 0 TRUE #> 3 Census API Date/Time Specification datetime N/A 0 TRUE #> 4 int N/A 0 #> 5 int N/A 0 #> 6 string N/A 0 #> required #> 1 #> 2 #> 3 true #> 4 #> 5 #> 6 default displayed # type: variables for a single variable group # List the variables that are included in the B17020 group in the # 5-year American Community Survey. variable_group <- listCensusMetadata( name = \"acs/acs5\", vintage = 2022, type = \"variables\", group = \"B17020\") head(variable_group) #> name #> 1 B17020_017EA #> 2 B17020_016MA #> 3 B17020_016EA #> 4 B17020_015MA #> 5 B17020_015EA #> 6 B17020_014EA #> label #> 1 Annotation of Estimate!!Total:!!Income in the past 12 months at or above poverty level:!!85 years and over #> 2 Annotation of Margin of Error!!Total:!!Income in the past 12 months at or above poverty level:!!75 to 84 years #> 3 Annotation of Estimate!!Total:!!Income in the past 12 months at or above poverty level:!!75 to 84 years #> 4 Annotation of Margin of Error!!Total:!!Income in the past 12 months at or above poverty level:!!60 to 74 years #> 5 Annotation of Estimate!!Total:!!Income in the past 12 months at or above poverty level:!!60 to 74 years #> 6 Annotation of Estimate!!Total:!!Income in the past 12 months at or above poverty level:!!18 to 59 years #> concept predicateType group limit #> 1 Poverty Status in the Past 12 Months by Age string B17020 0 #> 2 Poverty Status in the Past 12 Months by Age string B17020 0 #> 3 Poverty Status in the Past 12 Months by Age string B17020 0 #> 4 Poverty Status in the Past 12 Months by Age string B17020 0 #> 5 Poverty Status in the Past 12 Months by Age string B17020 0 #> 6 Poverty Status in the Past 12 Months by Age string B17020 0 #> predicateOnly universe #> 1 TRUE Population for whom poverty status is determined #> 2 TRUE Population for whom poverty status is determined #> 3 TRUE Population for whom poverty status is determined #> 4 TRUE Population for whom poverty status is determined #> 5 TRUE Population for whom poverty status is determined #> 6 TRUE Population for whom poverty status is determined # type: variables, with value labels # Create a data dictionary with all variable names and encoded values # for a microdata API. variable_values <- listCensusMetadata( name = \"cps/voting/nov\", vintage = 2020, type = \"variables\", include_values = TRUE) head(variable_values) #> name label #> 1 for Census API FIPS 'for' clause #> 2 in Census API FIPS 'in' clause #> 3 ucgid Uniform Census Geography Identifier clause #> 4 PEEDUCA Demographics-highest level of school completed #> 5 PEEDUCA Demographics-highest level of school completed #> 6 PEEDUCA Demographics-highest level of school completed #> concept predicateType group limit predicateOnly #> 1 Census API Geography Specification fips-for N/A 0 TRUE #> 2 Census API Geography Specification fips-in N/A 0 TRUE #> 3 Census API Geography Specification ucgid N/A 0 TRUE #> 4 int N/A 0 #> 5 int N/A 0 #> 6 int N/A 0 #> suggested_weight is_weight values_code values_label #> 1 #> 2 #> 3 #> 4 PWSSWGT 46 DOCTORATE DEGREE(EX:PhD,EdD) #> 5 PWSSWGT 33 5th Or 6th Grade #> 6 PWSSWGT 44 MASTER'S DEGREE(EX:MA,MS,MEng,MEd,MSW) # type: geographies # List the geographies available in the 5-year American Community Survey. geographies <- listCensusMetadata( name = \"acs/acs5\", vintage = 2022, type = \"geographies\") head(geographies) #> name geoLevelDisplay referenceDate requires wildcard #> 1 us 010 2022-01-01 NULL NULL #> 2 region 020 2022-01-01 NULL NULL #> 3 division 030 2022-01-01 NULL NULL #> 4 state 040 2022-01-01 NULL NULL #> 5 county 050 2022-01-01 state state #> 6 county subdivision 060 2022-01-01 state, county county #> optionalWithWCFor #> 1 #> 2 #> 3 #> 4 #> 5 state #> 6 county # type: groups # List the variable groups available in the 5-year American # Community Survey. groups <- listCensusMetadata( name = \"acs/acs5\", vintage = 2022, type = \"groups\") head(groups) #> name #> 1 B17015 #> 2 B18104 #> 3 B17016 #> 4 B18105 #> 5 B17017 #> 6 B18106 #> description #> 1 Poverty Status in the Past 12 Months of Families by Family Type by Social Security Income by Supplemental Security Income (SSI) and Cash Public Assistance Income #> 2 Sex by Age by Cognitive Difficulty #> 3 Poverty Status in the Past 12 Months of Families by Family Type by Work Experience of Householder and Spouse #> 4 Sex by Age by Ambulatory Difficulty #> 5 Poverty Status in the Past 12 Months by Household Type by Age of Householder #> 6 Sex by Age by Self-Care Difficulty #> variables #> 1 http://api.census.gov/data/2022/acs/acs5/groups/B17015.json #> 2 http://api.census.gov/data/2022/acs/acs5/groups/B18104.json #> 3 http://api.census.gov/data/2022/acs/acs5/groups/B17016.json #> 4 http://api.census.gov/data/2022/acs/acs5/groups/B18105.json #> 5 http://api.census.gov/data/2022/acs/acs5/groups/B17017.json #> 6 http://api.census.gov/data/2022/acs/acs5/groups/B18106.json #> universe #> 1 Families #> 2 Civilian noninstitutionalized population 5 years and over #> 3 Families #> 4 Civilian noninstitutionalized population 5 years and over #> 5 Households #> 6 Civilian noninstitutionalized population 5 years and over # type: values for a single variable # List the value labels of the NAICS2017 variable in the County # Business Patterns dataset. naics_values <- listCensusMetadata( name = \"cbp\", vintage = 2021, type = \"values\", variable = \"NAICS2017\") head(naics_values) #> code label #> 1 00 Total for all sectors #> 2 000000 Industry total #> 3 11 Agriculture, forestry, fishing and hunting #> 4 111 Crop production #> 5 1111 Oilseed and grain farming #> 6 11111 Soybean farming"},{"path":"https://www.hrecht.com/censusapi/reference/makeVarlist.html","id":null,"dir":"Reference","previous_headings":"","what":"Use variable metadata to find variables containing a given string — makeVarlist","title":"Use variable metadata to find variables containing a given string — makeVarlist","text":"Return list variable names data frame variable metadata containing given string. can used create list variables later pass getCensus, data frame documenting variables used given project.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/makeVarlist.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Use variable metadata to find variables containing a given string — makeVarlist","text":"","code":"makeVarlist(name, vintage = NULL, find, varsearch = \"all\", output = \"list\")"},{"path":"https://www.hrecht.com/censusapi/reference/makeVarlist.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Use variable metadata to find variables containing a given string — makeVarlist","text":"name API programmatic name - e.g. acs/acs5. Use listCensusApis() see valid dataset names. vintage Vintage (year) dataset. required timeseries APIs. find string find variable metadata. varsearch Optional argument specifying fields search. Default \"\". Options \"\", \"name\", \"label\", \"concept\". output Optional argument, specifying output \"list\" \"dataframe\". Default \"list\".","code":""},{"path":"https://www.hrecht.com/censusapi/reference/makeVarlist.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Use variable metadata to find variables containing a given string — makeVarlist","text":"data frame containing variable metadata","code":""},{"path":[]},{"path":"https://www.hrecht.com/censusapi/reference/makeVarlist.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Use variable metadata to find variables containing a given string — makeVarlist","text":"","code":"# Return a list, and then use getCensus function to retrieve those variables myvars <- makeVarlist(name = \"timeseries/poverty/saipe\", find = \"Ages 0-4\", varsearch = \"label\") myvars #> [1] \"SAEPOVRT0_4_UB90\" \"SAEPOVRT0_4_MOE\" \"SAEPOVRT0_4_LB90\" \"SAEPOVRT0_4_PT\" #> [5] \"SAEPOV0_4_PT\" \"SAEPOVU_0_4\" \"SAEPOV0_4_MOE\" \"SAEPOV0_4_UB90\" #> [9] \"SAEPOV0_4_LB90\" saipe_dt <- getCensus(name = \"timeseries/poverty/saipe\", time = 2016, vars = myvars, region = \"state:*\") head(saipe_dt) #> time state SAEPOVRT0_4_UB90 SAEPOVRT0_4_MOE SAEPOVRT0_4_LB90 SAEPOVRT0_4_PT #> 1 2016 01 28.9 1.5 25.9 27.4 #> 2 2016 02 17.0 1.9 13.2 15.1 #> 3 2016 04 26.1 1.2 23.7 24.9 #> 4 2016 05 29.1 1.8 25.5 27.3 #> 5 2016 06 21.2 0.5 20.2 20.7 #> 6 2016 08 15.1 1.2 12.7 13.9 #> SAEPOV0_4_PT SAEPOVU_0_4 SAEPOV0_4_MOE SAEPOV0_4_UB90 SAEPOV0_4_LB90 #> 1 78675 287177 4418 83093 74257 #> 2 7919 52408 1021 8940 6898 #> 3 106817 428317 5131 111948 101686 #> 4 50341 184115 3246 53587 47095 #> 5 502432 2430975 13017 515449 489415 #> 6 46111 330815 3894 50005 42217"},{"path":[]},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"breaking-changes-0-9-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"censusapi 0.9.0 (development verison)","text":"Increases required version R >=3.0 >=3.5 (released 2018) based httr dependency.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"new-features-0-9-0","dir":"Changelog","previous_headings":"","what":"New features","title":"censusapi 0.9.0 (development verison)","text":"getCensus() longer requires key, use Census Bureau API key. Users still encouraged register use API key Census Bureau may rate limit IP addresses, required. (#87) New get_api_key() helper function retrieves value user’s stored Census Bureau API key saved environment variable provides warning message none found. listCensusApis() now optional name vintage parameters get metadata subset datasets single dataset. (#103)","code":"# Get metadata for all 2020 Decennial Census datasets apis_decennial_2020 <- listCensusApis(name = \"dec\", vintage = 2020) # Get metadata for all timeseries datasets apis_timeseries <- listCensusApis(name = \"timeseries\")"},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"minor-improvements-0-9-0","dir":"Changelog","previous_headings":"","what":"Minor improvements","title":"censusapi 0.9.0 (development verison)","text":"getCensus() automatically converts data columns Household Pulse Survey (name = \"timeseries/hps\") numeric.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"documentation-0-9-0","dir":"Changelog","previous_headings":"","what":"Documentation","title":"censusapi 0.9.0 (development verison)","text":"Function documentation improved better formatted. Examples updated use newly released datasets. new online frequently asked questions article improves documentation. new vignette included package build directs users website read web-articles.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-080","dir":"Changelog","previous_headings":"","what":"censusapi 0.8.0","title":"censusapi 0.8.0","text":"CRAN release: 2022-08-09 listCensusApis() new columns resulting data frame available API endpoints: API contact email address type: either Aggregate, Timeseries, Microdata. listCensusMetadata() new functionality use value metadata. particularly useful economic datasets microdata APIs. Use type = \"variables\" include_values = TRUE create dictionary value labels given dataset. get value labels single variable given dataset, use type = \"values\" variable = \"VARIABLE INTEREST\". Note: metadata, incredibly useful, exists datasets. datasets ’ll still need reference external files Census Bureau adds functionality. example, get value labels NAICS2017 County Business Patterns dataset: make full dictionary Current Population Survey Voting Patterns microdata API: getCensus() new option convert_variables re discussion (#68) (#80). default TRUE — previous versions, converts columns numbers R’s numeric data type. Setting convert variables = FALSE leaves columns original character data type returned Census Bureau. getCensus() improved data binding responses requests 50 variables manually specified. Occasionally large requests returned Census Bureau order, leading mismatched rows. fixes (#82). listCensusMetadata() now properly handles metadata attribute names new Microdata APIs contain invalid JSON. fixes (#84). Documentation examples updated. new vignette: Accessing microdata.","code":"cbp_naics_values <- listCensusMetadata( name = \"cbp\", vintage = 2020, type = \"values\", variable = \"NAICS2017\") cbp_dict <- listCensusMetadata( name = \"cbp\", vintage = 2020, type = \"variables\", include_values = TRUE)"},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-073","dir":"Changelog","previous_headings":"","what":"censusapi 0.7.3","title":"censusapi 0.7.3","text":"Properly types certain variables international trade timeseries APIs.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-072","dir":"Changelog","previous_headings":"","what":"censusapi 0.7.2","title":"censusapi 0.7.2","text":"Adds named parameter YEAR getCensus() per changes timeseries endpoints previously used TIME parameter. Updates examples using SAHIE SAIPE APIs per Census Bureau changes endpoints.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-071","dir":"Changelog","previous_headings":"","what":"censusapi 0.7.1","title":"censusapi 0.7.1","text":"CRAN release: 2020-10-14 Removes listCensusMetadata() masterlist examples used Business Dynamic Statistics endpoints, recently deprecated.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-070","dir":"Changelog","previous_headings":"","what":"censusapi 0.7.0","title":"censusapi 0.7.0","text":"CRAN release: 2020-09-07 Adds show_call option getCensus(), shows underlying API call (otherwise shown errors) link package documentation used. Converts improperly formatted string “N/” “NULL” values underlying Census data true NA values. Keeps 2017 NAICS variables characters, instead erroneously converting numeric. Parses endpoint numeric variables -character variable names numeric several popular endpoints: SAHIE, SAIPE, ZBP, CBP, PEP Decennial Response Rates. Removes examples deprecated 1990 2000 Decennial endpoints.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-061","dir":"Changelog","previous_headings":"","what":"censusapi 0.6.1","title":"censusapi 0.6.1","text":"Updates web link FIPS codes reference Census website reorganization. Adds examples Decennial Census response rates, updates several examples retrieve newer data. Removes example masterlist package due size, online .","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-060","dir":"Changelog","previous_headings":"","what":"censusapi 0.6.0","title":"censusapi 0.6.0","text":"CRAN release: 2019-04-13 Allows use miscellaneous paramaters getCensus(). allows users specify valid API argument name pass value, giving full access underlying Census Bureau APIs. Adds group parameter listCensusMetadata(). allows users get variable metadata specified variable group. Improves internal logic listCensusMetadata(). Add documentation examples using miscellaneous paramaters. Returns underlying API call error messages, particularly useful users needing Census Bureau. Specifies tract block group example due underlying API changes. Adds Contributor Code Conduct.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-050","dir":"Changelog","previous_headings":"","what":"censusapi 0.5.0","title":"censusapi 0.5.0","text":"Makes region optional argument getCensus, rather required. Pads fips codes stored fips dataset zeroes.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-041","dir":"Changelog","previous_headings":"","what":"censusapi 0.4.1","title":"censusapi 0.4.1","text":"CRAN release: 2018-08-19 Adds groups type option listCensusMetadata. Fixes bug listCensusMetadata variables call caused underlying Census API change, renamed validValues values endpoints. Converts variable metadata columns factors characters. Applies numeric conversion exclusions API endpoints. Improves language surrounding error messages Census Bureau returns. Updates 2010 Decennial Census examples use new 2010 dec/sf1 endpoint, replace 2010 sf1 endpoint August 30, 2018.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-040","dir":"Changelog","previous_headings":"","what":"censusapi 0.4.0","title":"censusapi 0.4.0","text":"Adds support NAICS code arguments used Business Patterns APIs, Economic Census APIs, Annual Survey Manufactures APIs.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-030","dir":"Changelog","previous_headings":"","what":"censusapi 0.3.0","title":"censusapi 0.3.0","text":"CRAN release: 2018-05-02 convert ACS annotation flag variables numeric columns. Puts lowercase variable name columns first (geographies), rather non-numeric columns. Changes punctuation returned column names underscores, removing repeated underscores trailing punctuation. Uses consistent spacing examples. Updates examples using ACS data latest year using new acs/acs5 endpoint adds variable group examples.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-021","dir":"Changelog","previous_headings":"","what":"censusapi 0.2.1","title":"censusapi 0.2.1","text":"CRAN release: 2017-08-01 Fixes bug listCensusMetadata variables call caused underlying Census API changes.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-020","dir":"Changelog","previous_headings":"","what":"censusapi 0.2.0","title":"censusapi 0.2.0","text":"CRAN release: 2017-06-06 Updated examples, documentation, vignette.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-012","dir":"Changelog","previous_headings":"","what":"censusapi 0.1.2","title":"censusapi 0.1.2","text":"Fixes bug caused single-row responses throw error","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-011","dir":"Changelog","previous_headings":"","what":"censusapi 0.1.1","title":"censusapi 0.1.1","text":"Uses https rather http requests. Census Bureau announced APIs https-beginning August 28, 2017. Note: change generally increased run time retrieving variable metadata listCensusMetadata. APIs, function run one second. lag may noticeable American Community Survey APIs, 40,000 variables. Improvements planned future releases. listCensusMetadata allows full word single letter argument type parameter","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-010","dir":"Changelog","previous_headings":"","what":"censusapi 0.1.0","title":"censusapi 0.1.0","text":"Scrapes http://api.census.gov/data.json rather .html listCensusApis, starts removing XML dependency. .json data also includes several fields present .html file, useful added returned data frame. Changes dataset used listCensusMetadata examples, mainly build/checks speed. Set getCensus(key) argument’s default value CENSUS_KEY .Renviron. Explicitly encourages Census key added .Renviron. (Users can always override given input.) Parses HTML response code. particularly important response Census APIs provided invalid keys. Removes fips code 72 (Puerto Rico) included fips dataset Puerto Rico included Census API datasets. Changes census key references examples Sys.getenv(“CENSUS_KEY”).","code":""}] +[{"path":"https://www.hrecht.com/censusapi/CODE_OF_CONDUCT.html","id":null,"dir":"","previous_headings":"","what":"Contributor Code of Conduct","title":"Contributor Code of Conduct","text":"contributors maintainers project, interest fostering open welcoming community, pledge respect people contribute reporting issues, posting feature requests, updating documentation, submitting pull requests patches, activities. committed making participation project harassment-free experience everyone, regardless level experience, gender, gender identity expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, nationality. Examples unacceptable behavior participants include: use sexualized language imagery Personal attacks Trolling insulting/derogatory comments Public private harassment Publishing ’s private information, physical electronic addresses, without explicit permission unethical unprofessional conduct Project maintainers right responsibility remove, edit, reject comments, commits, code, wiki edits, issues, contributions aligned Code Conduct. adopting Code Conduct, project maintainers commit fairly consistently applying principles every aspect managing project. Project maintainers follow enforce Code Conduct may permanently removed project team. code conduct applies within project spaces public spaces individual representing project community. Instances abusive, harassing, otherwise unacceptable behavior may reported opening issue contacting one project maintainers. Code Conduct adapted Contributor Covenant, version 1.2.0, available https://www.contributor-covenant.org/version/1/2/0/code--conduct.html","code":""},{"path":"https://www.hrecht.com/censusapi/articles/accessing-microdata.html","id":"about-microdata","dir":"Articles","previous_headings":"","what":"About microdata","title":"Accessing microdata","text":"Microdata contains individual-level responses: one row per person. vital tool perform custom analysis, great power comes great responsibility. Appropriately weighting individual-level responses required. ’ll often need work household relationships need handle responses aren’t universe question (example, removing children analysis college graduation rate.) ’re new working microdata ’ll need reading diving . resources Census Bureau: microdata use ? (video transcript) Census Microdata API User Guide (pdf) Microdata API documentation endpoints, censusapi retrieves data can perform analysis using methodology choice. ’re looking interactive microdata analysis tool, try data.census.gov microdata interactive tool IPUMS online data analysis tool. ’ve learned use microdata gained understanding weighting, getting data using censusapi simple.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/accessing-microdata.html","id":"getting-microdata-with-censusapi","dir":"Articles","previous_headings":"","what":"Getting microdata with censusapi","title":"Accessing microdata","text":"example, ’ll get data 2020 Current Population Survey Voting Supplement. survey asks people voted, , , includes useful demographic data. See available variables: CPS Voting supplement, get data method voting New York state using PES5 (Vote person mail?) PESEX (gender), along appropriate weighting variable, PWSSWGT. ’ll get data people response 1 (yes) PES1 (vote?).","code":"voting_vars <- listCensusMetadata( name = \"cps/voting/nov\", vintage = 2020, type = \"variables\") head(voting_vars) cps_voting <- getCensus( name = \"cps/voting/nov\", vintage = 2020, vars = c(\"PES5\", \"PESEX\", \"PWSSWGT\"), region = \"state:36\", PES1 = 1) head(cps_voting)"},{"path":"https://www.hrecht.com/censusapi/articles/accessing-microdata.html","id":"making-a-data-dictionary","dir":"Articles","previous_headings":"","what":"Making a data dictionary","title":"Accessing microdata","text":"microdata variables encoded, means data lot numbers instead text labels. data dictionary, includes definitions labels every variable dataset, helpful. possible listCensusMetasdata(include_values = \"TRUE) returns data dictionary one row variable-label pair. means 30 codes given variable, 30 rows data dictionary. Variables don’t value labels metadata one row. can also look meaning codes single variable using function, listCensusMetadata(). values PES5, variable “Vote person mail?”","code":"voting_dict <- listCensusMetadata( name = \"cps/voting/nov\", vintage = 2020, type = \"variables\", include_values = TRUE) head(voting_dict) PES5_values <- listCensusMetadata( name = \"cps/voting/nov\", vintage = 2020, type = \"values\", variable = \"PES5\") PES5_values"},{"path":"https://www.hrecht.com/censusapi/articles/accessing-microdata.html","id":"other-ways-to-access-microdata","dir":"Articles","previous_headings":"","what":"Other ways to access microdata","title":"Accessing microdata","text":"Census Bureau microdata APIs helpful working limited just-released datasets. ’re option. ways get microdata : Retrieve standardized, cleaned microdata data IPUMS import impumsr package. IPUMS widely used research data needed brand new. highly recommend check IPUMS’ cleaned files microdata files well historic geographic data. standardized files generally released months year raw Census microdata available directly Census Bureau. Download complete bulk files Census FTPs (file transfer protocols.) helpful need large number variables. might run size limitations getting many variables APIs. Retrieve American Community Survey microdata via Census APIs tidycensus, helpful functions working endpoints.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"american-community-survey","dir":"Articles","previous_headings":"","what":"American Community Survey","title":"censusapi examples","text":"multiple useful ACS datasets slightly different purposes. ’s Census Bureau describes :","code":"\"Detailed Tables contain the most detailed cross-tabulations, many of which are published down to block groups. The data are population counts. There are over 20,000 variables in this dataset. Subject Tables provide an overview of the estimates available in a particular topic. The data are presented as population counts and percentages. There are over 18,000 variables in this dataset. Data Profiles contain broad social, economic, housing, and demographic information. The data are presented as population counts and percentages. There are over 1,000 variables in this dataset. Comparison Profiles are similar to Data Profiles but also include comparisons with past-year data. The current year data are compared with prior 5-Year data and include statistical significance testing. There are over 1,000 variables in this dataset.\""},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"acs-detailed-tables","dir":"Articles","previous_headings":"American Community Survey","what":"ACS Detailed Tables","title":"censusapi examples","text":"Get total population median income places (towns, cities, etc) Indiana.","code":"acs_income <- getCensus( name = \"acs/acs5\", vintage = 2022, vars = c(\"NAME\", \"B01001_001E\", \"B19013_001E\"), region = \"place:*\", regionin = \"state:18\") head(acs_income)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"acs-subject-tables","dir":"Articles","previous_headings":"American Community Survey","what":"ACS Subject Tables","title":"censusapi examples","text":"Get percent people without internet subscription income five counties New York City, associated margins error: overall: S2801_C02_019E income less $20,000: S2801_C02_023E income $20,000 $74,999: S2801_C02_027E income $75,000 greater: S2801_C02_031E","code":"acs_subject <- getCensus( name = \"acs/acs1/subject\", vintage = 2022, vars = c(\"NAME\", \"S2801_C02_019E\", \"S2801_C02_019M\", \"S2801_C02_023E\", \"S2801_C02_023M\", \"S2801_C02_027E\", \"S2801_C02_027M\", \"S2801_C02_031E\", \"S2801_C02_031M\"), region = \"county:005,047,061,081,085\", regionin = \"state:36\") head(acs_subject)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"acs-comparison-profiles","dir":"Articles","previous_headings":"American Community Survey","what":"ACS Comparison Profiles","title":"censusapi examples","text":"Get annual median household income inflation-adjusted 2019 dollars Alabama cities since 2018. (2020 1-year data available.)","code":"acs_comparison <- getCensus( name = \"acs/acs1/cprofile\", vintage = 2022, vars = c(\"NAME\", \"CP03_2018_062E\", \"CP03_2019_062E\", \"CP03_2021_062E\", \"CP03_2022_062E\"), region = \"place:*\", regionin = \"state:01\") head(acs_comparison)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"acs-migration-flows","dir":"Articles","previous_headings":"American Community Survey","what":"ACS Migration Flows","title":"censusapi examples","text":"American Community Survey Migration Flows documentation Get number people moved Los Angeles county origin destination.","code":"flows <- getCensus( name = \"acs/flows\", vintage = 2019, vars = c(\"MOVEDIN\", \"MOVEDOUT\", \"GEOID2\", \"FULL1_NAME\", \"FULL2_NAME\"), region = \"county:037\", regionin = \"state:06\") head(flows, n = 15L)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"american-community-survey-language-statistics","dir":"Articles","previous_headings":"American Community Survey","what":"American Community Survey Language Statistics","title":"censusapi examples","text":"American Community Survey Language Statistics documentation Get number people New York state speak language.","code":"languages <- getCensus( name = \"language\", vintage = 2013, vars = c(\"EST\", \"LAN\", \"LANLABEL\"), region = \"state:36\") head(languages)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"annual-survey-of-entrepreneurs","dir":"Articles","previous_headings":"","what":"Annual Survey of Entrepreneurs","title":"censusapi examples","text":"Annual Survey Entrepreneurs documentation","code":"ase_csa <- getCensus( name = \"ase/csa\", vintage = 2014, vars = c(\"GEO_TTL\", \"NAICS2012\", \"NAICS2012_TTL\", \"EMPSZFI\", \"EMPSZFI_TTL\", \"FIRMPDEMP\"), region = \"us:*\") head(ase_csa) ase_cscb <- getCensus( name = \"ase/cscb\", vintage = 2014, vars = c(\"GEO_TTL\", \"NAICS2012_TTL\", \"ASECB\", \"ASECB_TTL\", \"SPOUSES\", \"SPOUSES_TTL\", \"YEAR\", \"FIRMPDEMP\", \"FIRMPDEMP_PCT\", \"RCPPDEMP\", \"RCPPDEMP_F\", \"RCPPDEMP_PCT\", \"EMP\", \"EMP_PCT\", \"PAYANN\", \"PAYANN_PCT\", \"FIRMPDEMP_S\", \"FIRMPDEMP_PCT_S\", \"RCPPDEMP_S\", \"RCPPDEMP_PCT_S\", \"EMP_S\", \"EMP_PCT_S\", \"PAYANN_S\", \"PAYANN_PCT_S\"), region = \"us:*\") head(ase_cscb) ase_cscbo <- getCensus( name = \"ase/cscbo\", vintage = 2014, vars = c(\"GEO_TTL\", \"NAICS2012_TTL\", \"ASECBO\", \"ASECBO_TTL\", \"ACQBUS\", \"ACQBUS_TTL\", \"YEAR\", \"OWNPDEMP\", \"OWNPDEMP_PCT\", \"OWNPDEMP_S\", \"OWNPDEMP_PCT_S\"), region = \"us:*\") head(ase_cscbo)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"annual-survey-of-manufactures","dir":"Articles","previous_headings":"","what":"Annual Survey of Manufactures","title":"censusapi examples","text":"Annual Survey Manufactures documentation","code":"asm_state <- getCensus( name = \"timeseries/asm/state\", vars = c(\"GEO_TTL\", \"NAICS_TTL\", \"EMP\"), region = \"state:*\", time = 2016, NAICS = \"31-33\") head(asm_state) asm_product <- getCensus( name = \"timeseries/asm/product\", vars = c(\"PSCODE_TTL\", \"GEO_TTL\", \"PRODVAL\"), region = \"us:*\", time = 2016, PSCODE = 311111) head(asm_product)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"community-resiliency-estimates","dir":"Articles","previous_headings":"","what":"Community Resiliency Estimates","title":"censusapi examples","text":"Community Resilience Estimates documentation Census tracts single county, get rate individuals zero components social vulnerability, one-two components social vulnerability, three components social vulnerability.","code":"cre <- getCensus( name = \"cre\", vintage = 2022, vars = c(\"PRED0_PE\", \"PRED12_PE\", \"PRED3_PE\"), region = \"tract:*\", regionin = \"state:01&county:001\") head(cre)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"county-business-patterns-and-nonemployer-statistics","dir":"Articles","previous_headings":"","what":"County Business Patterns and Nonemployer Statistics","title":"censusapi examples","text":"County Business Patterns Nonemployer Statistics documentation","code":""},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"county-business-patterns","dir":"Articles","previous_headings":"County Business Patterns and Nonemployer Statistics","what":"County Business Patterns","title":"censusapi examples","text":"County Business Patterns documentation Get employment data construction industry. Get number companies employees organizations 1,000 employees (EMPSZES = 260).","code":"cbp <- getCensus( name = \"cbp\", vintage = 2021, vars = c(\"EMP\", \"ESTAB\"), region = \"state:*\", NAICS2017 = 23) head(cbp) cbp_large_companies <- getCensus( name = \"cbp\", vintage = 2021, vars = c(\"NAME\", \"EMP\", \"ESTAB\"), region = \"state:*\", EMPSZES = 260) head(cbp_large_companies)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"zip-codes-business-patterns","dir":"Articles","previous_headings":"County Business Patterns and Nonemployer Statistics","what":"Zip Codes Business Patterns","title":"censusapi examples","text":"Zip Codes Business Patterns documentation","code":"zbp_2018 <- getCensus( name = \"zbp\", vintage = 2018, vars = c(\"EMP\", \"ESTAB\", \"EMPSZES\"), region = \"zipcode:90210\") head(zbp_2018)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"nonemployer-statistics","dir":"Articles","previous_headings":"County Business Patterns and Nonemployer Statistics","what":"Nonemployer statistics","title":"censusapi examples","text":"Nonemployer statistics documentation Get number nonemployer establishments MSA sector 54, Professional, scientific, technical services.","code":"nonemp <- getCensus( name = \"nonemp\", vintage = 2021, vars = c(\"NAME\", \"NESTAB\", \"NAICS2017_LABEL\"), region = \"metropolitan statistical area/micropolitan statistical area:*\", NAICS2017 = 54) head(nonemp)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"decennial-census","dir":"Articles","previous_headings":"","what":"Decennial Census","title":"censusapi examples","text":"Decennial Census documentation","code":""},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"decennial-census-1","dir":"Articles","previous_headings":"Decennial Census","what":"2020 Decennial Census","title":"censusapi examples","text":"Using 2020 Demographic Profile, get percent population age 65 older (DP1_0024P) metro micropolitan statistical areas. Using 2020 Demographic Housing Characteristics File, get total number households (H9_001N) number 1-person households (H9_002N) counties Maryland. can use Detailed Demographic Housing Characteristics File (Detailed DHC-) get detailed data specific race ethnicity groups. First, check value labels POPGROUP variable. Get total population (T01001_001N) people Japanese alone combination (POPGROUP code 3824) state.","code":"dec_elderly <- getCensus( name = \"dec/dp\", vintage = 2020, vars = c(\"NAME\", \"DP1_0024P\"), region = \"metropolitan statistical area/micropolitan statistical area:*\") head(dec_elderly) dec <- getCensus( name = \"dec/dhc\", vintage = 2020, vars = c(\"NAME\", \"H9_001N\", \"H9_002N\"), region = \"county:*\", regionin = \"state:24\") head(dec) popgroup_values <- listCensusMetadata( name = \"dec/ddhca\", vintage = 2020, type = \"values\", variable_name = \"POPGROUP\") head(popgroup_values) dec_population <- getCensus( name = \"dec/ddhca\", vintage = 2020, vars = c(\"NAME\", \"T01001_001N\", \"POPGROUP_LABEL\"), region = \"state:*\", POPGROUP = 3824) head(dec_population)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"decennial-census-2","dir":"Articles","previous_headings":"Decennial Census","what":"2010 Decennial Census","title":"censusapi examples","text":"Get total population number housing units metropolitan/micropolitan statistical areas 2010. Get urban/rural status group variables (P2) metropolitan/micropolitan statistical areas 2010. Get 2010 population block group within specific tract.","code":"data2010 <- getCensus( name = \"dec/sf1\", vintage = 2010, vars = c(\"NAME\", \"P001001\", \"H010001\"), region = \"metropolitan statistical area/micropolitan statistical area:*\") head(data2010) # Show variable metadata for the P2 group group_p2 <- listCensusMetadata( name = \"dec/sf1\", vintage = 2010, type = \"variables\", group = \"P2\") # Get the P2 variable group (URBAN AND RURAL) data2010 <- getCensus( name = \"dec/sf1\", vintage = 2010, vars = \"group(P2)\", region = \"metropolitan statistical area/micropolitan statistical area:*\") head(data2010) tract_pop <- getCensus( name = \"dec/sf1\", vintage = 2010, vars = \"P001001\", region = \"block:*\", regionin = \"state:36+county:027+tract:010000\") head(tract_pop)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"decennial-census-self-response-rates","dir":"Articles","previous_headings":"Decennial Census","what":"Decennial Census Self-Response Rates","title":"censusapi examples","text":"Decennial Census Self-Response Rates documentation Get self-response rates 2020 2010 Decennial Census state, county, tract, place . Get overall internet repose rates counties. Get response rates places (cities, towns, etc) within New York state. Get final 2010 Decennial Census self-response rates.","code":"county_responses <- getCensus( name = \"dec/responserate\", vintage = 2020, vars = c(\"NAME\", \"RESP_DATE\", \"CRRALL\", \"CRRINT\"), region = \"county:*\") head(county_responses) ny_place_responses <- getCensus( name = \"dec/responserate\", vintage = 2020, vars = c(\"NAME\", \"RESP_DATE\", \"CRRALL\", \"CRRINT\"), region = \"place:*\", regionin = \"state:36\") head(ny_place_responses) county_responses_2010 <- getCensus( name = \"dec/responserate\", vintage = 2010, vars = c(\"NAME\", \"FSRR2010\"), region = \"county:*\") head(county_responses_2010)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"decennial-census-surname-files","dir":"Articles","previous_headings":"Decennial Census","what":"Decennial Census Surname Files","title":"censusapi examples","text":"Decennial Census Surname documentation Get counts top 25 popular surnames share race.","code":"top_surnames <- getCensus( name = \"surname\", vintage = 2010, vars = c(\"NAME\", \"COUNT\", \"PROP100K\", \"PCTWHITE\", \"PCTBLACK\", \"PCTAIAN\", \"PCTAPI\", \"PCTHISPANIC\", \"PCT2PRACE\"), RANK = \"1:25\") head(top_surnames)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"economic-census","dir":"Articles","previous_headings":"","what":"Economic Census","title":"censusapi examples","text":"Economic Census documentation","code":"ewks_2012 <- getCensus( name = \"ewks\", vintage = 2012, vars = c(\"EMP\", \"OPTAX\", \"GEOTYPE\"), region = \"state:*\", NAICS2012 = 54) head(ewks_2012) ewks_2007 <- getCensus( name = \"ewks\", vintage = 2007, vars = c(\"EMP\", \"OPTAX\", \"GEOTYPE\"), region = \"state:*\", NAICS2007 = 54) head(ewks_2007)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"economic-indicators","dir":"Articles","previous_headings":"","what":"Economic Indicators","title":"censusapi examples","text":"Economic Indicators documentation","code":"eits <- getCensus( name = \"timeseries/eits/resconst\", vars = c(\"cell_value\", \"data_type_code\", \"time_slot_id\", \"error_data\", \"category_code\", \"seasonally_adj\"), region = \"us:*\", time = \"from 2023-01\") head(eits)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"health-insurance-small-area-health-insurance-estimates","dir":"Articles","previous_headings":"","what":"Health Insurance: Small Area Health Insurance Estimates","title":"censusapi examples","text":"Health Insurance Statistics documentation Get uninsured rate income group county single year. Get uninsured rate county 2006 latest year available. Get uninsured rate non-elderly adults (AGECAT = 1) incomes 138 400% poverty line (IPRCAT = 5), race state.","code":"sahie <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"IPRCAT\", \"IPR_DESC\", \"PCTUI_PT\"), region = \"county:*\", time = 2021) head(sahie) sahie_annual <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"PCTUI_PT\"), region = \"county:037\", regionin = \"state:06\", time = \"from 2006\") sahie_annual sahie_adults <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"PCTUI_PT\", \"RACECAT\", \"RACE_DESC\"), region = \"state:*\", time = 2021, IPRCAT = 5, AGECAT = 1) head(sahie_adults)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"household-pulse-survey","dir":"Articles","previous_headings":"","what":"Household Pulse Survey","title":"censusapi examples","text":"Household Pulse Survey documentation Get food scarcity rate (Percentage adults households either sometimes often enough eat last 7 days) expense difficulty rate (Percentage adults households somewhat difficult pay usual household expenses last 7 days) every state one survey period. Get national food scarcity rate expense difficulty rate every survey period available since 2022.","code":"hps_state <- getCensus( name = \"timeseries/hps\", vars = c(\"NAME\", \"FOODSCARCE_RATE\", \"EXPENSE_RATE\", \"COL_START_DATE\", \"COL_END_DATE\"), region = \"state:*\", WEEK = 63, time = 2023) head(hps_state) hps_us <- getCensus( name = \"timeseries/hps\", vars = c(\"FOODSCARCE_RATE\", \"EXPENSE_RATE\", \"COL_START_DATE\", \"COL_END_DATE\"), region = \"us:*\", WEEK = \"*\", time = \"from 2022\") hps_us"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"international-data-base","dir":"Articles","previous_headings":"","what":"International Data Base","title":"censusapi examples","text":"International Data Base documentation Get Census Bureau projections 2024 populations life expectancy birth country.","code":"intl_pop <- getCensus( name = \"timeseries/idb/5year\", vars = c(\"NAME\", \"GENC\", \"POP\", \"E0\"), time = 2024) head(intl_pop)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"international-trade","dir":"Articles","previous_headings":"","what":"International Trade","title":"censusapi examples","text":"International Trade documentation Note: international trade datasets can buggy often give general error message “error running query. ’ve logged error ’ll correct ASAP. Sorry inconvenience.” error message comes U.S. Census Bureau. run repeated issues inconsistencies, contact Census Bureau help consider using bulk data download instead. Get general imports value imports consumption value countries specific month.","code":"imports <- getCensus( name = \"timeseries/intltrade/imports/enduse\", vars = c(\"CTY_CODE\", \"CTY_NAME\", \"GEN_VAL_MO\", \"CON_VAL_MO\"), time = \"2024-01\") head(imports)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"population-estimates-and-projections","dir":"Articles","previous_headings":"","what":"Population Estimates and Projections","title":"censusapi examples","text":"Population Estimates Projections documentation","code":""},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"population-estimates","dir":"Articles","previous_headings":"Population Estimates and Projections","what":"Population Estimates","title":"censusapi examples","text":"Population Estimates documentation PEP data 2022 beyond currently available via API. can download latest data files PEP webpage. Get 2021 vintage population estimates states 2020 2021.","code":"popest <- getCensus( name = \"pep/population\", vintage = 2021, vars = c(\"POP_2020\",\"POP_2021\"), region = \"state:*\") head(popest) popest_housing <- getCensus( name = \"pep/housing\", vintage = 2018, vars = c(\"DATE_CODE\", \"DATE_DESC\", \"HUEST\"), region = \"county:195\", regionin = \"state:02\") head(popest_housing)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"population-projections","dir":"Articles","previous_headings":"Population Estimates and Projections","what":"Population Projections","title":"censusapi examples","text":"Population Projections documentation","code":"popproj <- getCensus( name = \"pep/projpop\", vintage = 2014, vars = c(\"YEAR\", \"POP\", \"AGE\"), region = \"us:1\") head(popproj)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"poverty-statistics","dir":"Articles","previous_headings":"","what":"Poverty Statistics","title":"censusapi examples","text":"Poverty Statistics documentation","code":""},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"current-population-survey-poverty-statistics","dir":"Articles","previous_headings":"Poverty Statistics","what":"Current Population Survey Poverty Statistics","title":"censusapi examples","text":"Get national poverty rates race since 1970.","code":"poverty <- getCensus( name = \"timeseries/poverty/histpov2\", vars = c(\"RACE\", \"RACE_LABEL\", \"PCTPOV\"), region = \"us:*\", time = \"from 1970\") head(poverty)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"small-area-income-and-poverty-estimates-saipe","dir":"Articles","previous_headings":"Poverty Statistics","what":"Small Area Income and Poverty Estimates (SAIPE)","title":"censusapi examples","text":"Get poverty rate children overall single year. Get poverty rate children overall single county time.","code":"saipe <- getCensus( name = \"timeseries/poverty/saipe\", vars = c(\"NAME\", \"SAEPOVRT0_17_PT\", \"SAEPOVRTALL_PT\"), region = \"state:*\", time = 2022) head(saipe) saipe_years <- getCensus( name = \"timeseries/poverty/saipe\", vars = c(\"NAME\", \"SAEPOVRT0_17_PT\", \"SAEPOVRTALL_PT\"), region = \"county:001\", regionin = \"state:12\", time = \"from 2010\") head(saipe_years)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"saipe-school-districts","dir":"Articles","previous_headings":"Poverty Statistics","what":"SAIPE School Districts","title":"censusapi examples","text":"Get number (SAEPOV5_17V_PT) rate (SAEPOVRAT5_17RV_PT) children ages 5-17 living poverty unified school districts Massachusetts.","code":"saipe_schools <- getCensus( name = \"timeseries/poverty/saipe/schdist\", vars = c(\"SD_NAME\", \"SAEPOV5_17V_PT\", \"SAEPOVRAT5_17RV_PT\"), region = \"school district (unified):*\", regionin = \"state:25\", time = 2022) head(saipe_schools)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"public-sector-statistics","dir":"Articles","previous_headings":"","what":"Public Sector Statistics","title":"censusapi examples","text":"Public Sector Statistics documentation endpoint includes data multiple surveys organized sure read Census Bureau’s documentation variable definitions labels. Get expenditures Public Elementary-Secondary School System Finances Massachusetts.","code":"govs <- getCensus( name = \"timeseries/govs\", vars = c(\"SVY_COMP_LABEL\", \"AGG_DESC\", \"AGG_DESC_LABEL\" ,\"AMOUNT\"), region = \"state:25\", time = 2021, SVY_COMP = \"06\", EXPENDTYPE = \"001\") head(govs)"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"quarterly-workforce-indicators","dir":"Articles","previous_headings":"","what":"Quarterly Workforce Indicators","title":"censusapi examples","text":"Quarterly Workforce Indicators documentation QWI endpoints allow simple calls specific ones. Make sure read documentation closely. ’s simple call gets employment data county. Got total employment average earnings quarter single state. ’s much specific call. Read Census Bureau’s documentation closely see options allowed QWI APIs.","code":"qwi_counties <- getCensus( name = \"timeseries/qwi/sa\", vars = c(\"Emp\", \"EarnBeg\"), region = \"county:*\", regionin = \"state:01\", time = \"2023-Q2\") head(qwi_counties) qwi_time <- getCensus( name = \"timeseries/qwi/sa\", vars = c(\"Emp\", \"EarnBeg\"), region = \"state:01\", time = \"from 2018 to 2023\") head(qwi_time) qwi <- getCensus( name = \"timeseries/qwi/sa\", region = \"state:02\", vars = c(\"Emp\", \"sex\"), time = 2012, quarter = 1, agegrp = \"A07\", ownercode = \"A05\", firmsize = 1, seasonadj = \"U\", industry = 21) qwi"},{"path":"https://www.hrecht.com/censusapi/articles/example-list.html","id":"the-planning-database","dir":"Articles","previous_headings":"","what":"The Planning Database","title":"censusapi examples","text":"Planning Database documentation Get population 2010 Census mail return rates block groups Autauga County, AL.","code":"pdb <- getCensus( name = \"pdb/blockgroup\", vintage = 2018, vars = c(\"GIDBG\", \"County_name\", \"State_name\", \"Tot_Population_CEN_2010\", \"Mail_Return_Rate_CEN_2010\"), region = \"block group:*\", regionin = \"state:01+county:001\") head(pdb)"},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"how-do-i-learn-more-about-a-particular-dataset","dir":"Articles","previous_headings":"","what":"How do I learn more about a particular dataset?","title":"Frequently asked questions","text":"Read online documentation survey. information included developer metadata documentation pages available PDFs Census Bureau website.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"how-can-i-see-the-underlying-api-call-sent-to-the-census-bureau","dir":"Articles","previous_headings":"","what":"How can I see the underlying API call sent to the Census Bureau?","title":"Frequently asked questions","text":"can see underlying API call sent Census Bureau servers setting getCensus(show_call = TRUE) running code. getCensus() call results error, automatically print underlying API call R console. can copy paste URL web browser view directly.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"what-does-there-was-an-error-while-running-your-query-mean","dir":"Articles","previous_headings":"","what":"What does “There was an error while running your query” mean?","title":"Frequently asked questions","text":"Occasionally might get general error message “error running query. logged error correct ASAP. Sorry inconvenience.” comes Census Bureau caused number problems, including server issues. Try rerunning API call. doesn’t work requesting large amount data, try reducing amount ’re requesting. ’re still trouble, see ways get help.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"my-getcensus-call-worked-last-year-but-now-it-gives-an-error--why","dir":"Articles","previous_headings":"","what":"My getCensus() call worked last year but now it gives an error. Why?","title":"Frequently asked questions","text":"Census Bureau makes frequent changes APIs. annual datasets, like American Community Survey, variable names available geographies can change year year. Options timeseries datasets sometimes change new releases. Check Census Bureau’s online documentation dataset use listCensusMetadata() make sure ’re using current syntax.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"are-the-census-apis-case-sensitive","dir":"Articles","previous_headings":"","what":"Are the Census APIs case sensitive?","title":"Frequently asked questions","text":"Yes. Run listCensusMetadata(type = \"variables\") dataset see variables available. variable name want uppercase ’ll need write uppercase getCensus() request. APIs use uppercase, use lowercase even use sentence case variable names.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"how-do-i-know-what-geographies-are-available-for-my-dataset-what-is-a-fips-code","dir":"Articles","previous_headings":"","what":"How do I know what geographies are available for my dataset? What is a FIPS code?","title":"Frequently asked questions","text":"Run listCensusMetadata(type = \"geographies\") dataset check geographies can use. API list valid geographies occasionally change Census Bureau makes updates. geographies Census APIs specified using FIPS (Federal Information Processing Standards) codes. example, Autauga County, Alabama assigned state code 01 county code 001. combined GEOID, uniquely identifies counties nationally, 01001. See Census Bureau FIPS reference valid codes geographic glossary information. can also download geographic identifying information Census gazetteer files, including full GEOID, name, centroid coordinates. FIPS codes characters, numbers. example, state-level FIPS codes two characters long. region = state:01 work region =``state:1 usually .","code":""},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"how-do-i-get-data-for-every-state-county-or-metro-area","dir":"Articles","previous_headings":"","what":"How do I get data for every state, county, or metro area?","title":"Frequently asked questions","text":"Census datasets allow use wildcard — * symbol — get data geography class. example, can get data every state American Community Survey using region = state:*. Data small geographies, like Census tract block group, need nested using regionin argument. Run listCensusMetadata(type = \"geographies\") see options. ’s example getting block group population data within specific Census tract using 2020 Decennial Census.","code":"state_data <- getCensus( name = \"acs/acs1\", vintage = 2022, vars = c(\"NAME\", \"B19013_001E\"), region = \"state:*\") head(state_data) block_group <- getCensus( name = \"dec/dhc\", vintage = 2020, vars = c(\"NAME\", \"P1_001N\"), region = \"block group:*\", regionin = \"state:36+county:027+tract:220300\") block_group"},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"im-still-stuck-or-got-an-unexpected-result--how-can-i-get-help","dir":"Articles","previous_headings":"","what":"I’m still stuck or got an unexpected result. How can I get help?","title":"Frequently asked questions","text":"Use listCensusMetadata() make sure ’re using right variable names /geography names. Join Census Bureau’s public Slack channel ask question R API rooms. Census Bureau staff censusapi users (censusapi package developer!) check Slack regularly. fastest way get help. Open Github issue bugs issues suspect caused R package. questions specific survey, can email contact listed dataset metadata found listCensusApis().","code":""},{"path":"https://www.hrecht.com/censusapi/articles/frequently-asked-questions.html","id":"why-is-my-data--666666666-or-another-weird-value-what-is-an-annotation","dir":"Articles","previous_headings":"","what":"Why is my data -666666666 or another weird value? What is an annotation?","title":"Frequently asked questions","text":"Census datasets, including American Community Survey, use annotated values. values use numbers symbols indicate data unavailable, top coded, insufficient sample size, noteworthy characteristics. Read Census Bureau ACS annotation meanings ACS variable types. censusapi package intended return data -can receive unaltered annotations. using data small geography like Census tract block group make sure check values like -666666666 check annotation columns non-empty values exclude needed. example, ’ll get total number households (B11012_001E) median household income associated annotations margins error (B19013 group) three census tracts Washington, DC. value one tract available, one top coded, one unavailable. Notice income top coded $250,000 — meaning tract’s income threshold listed $250,001. can see value special meaning “EA” (estimate annotation) “MA” (margin error annotation) columns.","code":"annotations_example <- getCensus( name = \"acs/acs5\", vintage = 2022, vars = c(\"B11012_001E\", \"group(B19013)\"), region = \"tract:006804,007703,000903\", regionin = \"county:001&state:11\") annotations_example"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"api-key-setup","dir":"Articles","previous_headings":"","what":"API key setup","title":"Getting started with censusapi","text":"censusapi recommends require using API key U.S. Census Bureau. Census Bureau may limit number requests made IP address use API key. can sign online receive key, sent provided email address. save key name CENSUS_KEY CENSUS_API_KEY Renviron file, censusapi use default without extra work part. save API key, within R, run: instances might want put key .Renviron - example, ’re shared school computer. can always choose manually set key = \"PASTEYOURKEYHERE\" argument getCensus() prefer.","code":"# Check to see if you already have a CENSUS_KEY or CENSUS_API_KEY saved # If so, no further action is needed get_api_key() # If not, add your key to your Renviron file Sys.setenv(CENSUS_KEY=PASTEYOURKEYHERE) # Reload .Renviron readRenviron(\"~/.Renviron\") # Check to see that the expected key is output in your R console get_api_key()"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"basic-usage","dir":"Articles","previous_headings":"","what":"Basic usage","title":"Getting started with censusapi","text":"main function censusapi getCensus(), makes API call given endpoint returns data frame results. API slightly different parameters, always required arguments: name: programmatic name endpoint defined Census, like “acs/acs5” “timeseries/bds/firms” vintage: survey year, required aggregate microdata APIs vars: list variables retrieve region: geography level retrieve, state county, required nearly endpoints APIs additional required optional arguments, like time timeseries datasets. Check specific documentation API explore metadata listCensusMetadata() see options allowed. Let’s walk example getting uninsured rates using Small Area Health Insurance Estimates API, provides detailed annual state-level county-level estimates health insurance rates people age 65.","code":""},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"choosing-variables","dir":"Articles","previous_headings":"Basic usage","what":"Choosing variables","title":"Getting started with censusapi","text":"censusapi includes metadata function called listCensusMetadata() get information API’s variable geography options. Let’s see variables available SAHIE API:","code":"library(censusapi) sahie_vars <- listCensusMetadata( name = \"timeseries/healthins/sahie\", type = \"variables\") # See the full list of variables sahie_vars$name #> [1] \"for\" \"in\" \"time\" \"NIPR_LB90\" \"NIPR_PT\" #> [6] \"AGECAT\" \"GEOID\" \"NIC_PT\" \"STATE\" \"RACE_DESC\" #> [11] \"YEAR\" \"IPRCAT\" \"PCTIC_UB90\" \"NIPR_MOE\" \"PCTUI_LB90\" #> [16] \"NIC_MOE\" \"US\" \"COUNTY\" \"PCTUI_MOE\" \"NUI_UB90\" #> [21] \"NIC_UB90\" \"NUI_MOE\" \"SEXCAT\" \"PCTUI_PT\" \"PCTIC_LB90\" #> [26] \"PCTUI_UB90\" \"NUI_PT\" \"STABREV\" \"AGE_DESC\" \"NAME\" #> [31] \"NIC_LB90\" \"PCTIC_PT\" \"PCTIC_MOE\" \"IPR_DESC\" \"NUI_LB90\" #> [36] \"NIPR_UB90\" \"GEOCAT\" \"SEX_DESC\" \"RACECAT\" # Full info on the first several variables head(sahie_vars)"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"choosing-regions","dir":"Articles","previous_headings":"Basic usage","what":"Choosing regions","title":"Getting started with censusapi","text":"can also use listCensusMetadata see geographic levels available. API three geographic levels: us, county, state. County data can queried counties nationally within specific state.","code":"listCensusMetadata( name = \"timeseries/healthins/sahie\", type = \"geographies\")"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"making-a-censusapi-call","dir":"Articles","previous_headings":"Basic usage","what":"Making a censusapi call","title":"Getting started with censusapi","text":"First, using getCensus(), let’s get percent (PCTUI_PT) number (NUI_PT) people uninsured, using wildcard star (*) retrieve data counties. can also get data detailed income demographic groups SAHIE. ’ll use region specify county-level results regionin filter Virginia, state code 51. ’ll get uninsured rates income group, IPRCAT. SAHIE API timeseries dataset, indicated name,, can get multiple years data changing time = YYYY time = \"YYYY YYYY\", get latest data available using time = \"YYYY\". Let’s get data DeKalb County, Georgia using county fips code 089 state fips code 13. can look fips codes Census Bureau website. can also filter data income group using IPRCAT variable. See possible values IPRCAT using listCensusMetadata(). IPRCAT = 3 represents <=138% federal poverty line. threshold Medicaid eligibility states expanded Affordable Care Act. Getting data Los Angeles county (fips code 06037) can see dramatic decrease uninsured rate income group California expanded Medicaid.","code":"sahie_counties <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"PCTUI_PT\", \"NUI_PT\"), region = \"county:*\", time = 2021) head(sahie_counties) sahie_virginia <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"IPRCAT\", \"IPR_DESC\", \"PCTUI_PT\"), region = \"county:*\", regionin = \"state:51\", time = 2021) head(sahie_virginia, head = 12L) sahie_years <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"PCTUI_PT\"), region = \"county:089\", regionin = \"state:13\", time = \"from 2006\") sahie_years listCensusMetadata( name = \"timeseries/healthins/sahie\", type = \"values\", variable = \"IPRCAT\") sahie_138 <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"PCTUI_PT\", \"NUI_PT\"), region = \"county:037\", regionin = \"state:06\", IPRCAT = 3, time = \"from 2010\") sahie_138"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"finding-your-api","dir":"Articles","previous_headings":"","what":"Finding your API","title":"Getting started with censusapi","text":"don’t already know dataset’s name? see current table every available endpoint, use listCensusApis(). data frame includes useful information making API call, including dataset’s name, vintage applicable, description, title. can also get information subset datasets using optional name /vintage parameters. example, get information 2020 Decennial Census datasets.","code":"apis <- listCensusApis() colnames(apis) #> [1] \"title\" \"name\" \"vintage\" \"type\" \"temporal\" #> [6] \"spatial\" \"url\" \"modified\" \"description\" \"contact\" dec_apis <- listCensusApis(name = \"dec\", vintage = 2020) dec_apis[, 1:6]"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"dataset-types","dir":"Articles","previous_headings":"Finding your API","what":"Dataset types","title":"Getting started with censusapi","text":"three types datasets included Census Bureau API universe: aggregate, microdata, timeseries. type names defined Census Bureau included column listCensusApis(). users work summary data, either aggregate timeseries. Summary data contains pre-calculated numbers percentages given statistic — like number children state median household income. examples broader list censusapi examples use summary data. Aggregate datasets, like American Community Survey Decennial Census, include data one time period (vintage), usually one year. Datasets like American Community Survey contain thousands pre-computed variables. Timeseries datasets, including Small Area Income Poverty Estimates, Quarterly Workforce Estimates, International Trade statistics, allow users query data time single API call. Microdata contains individual-level responses survey use custom analysis. One row represents one person. advanced analysts want use microdata. Learn microdata use censusapi Accessing microdata.","code":"table(apis$type) #> #> Aggregate Microdata Timeseries #> 624 895 81"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"variable-groups","dir":"Articles","previous_headings":"","what":"Variable groups","title":"Getting started with censusapi","text":"surveys, including American Community Survey Decennial Census, can get many related variables using variable group. groups defined Census Bureau. data tools, like data.census.gov, concept referred table. groups several dozen variables, others just . example, ’ll use American Community Survey get estimate, margin error annotations median household income past 12 months Census places (cities, towns, etc) Alabama using group B19013. First, see descriptions variables group B19013: Now, retrieve data using vars = \"group(B19013)\". alternatively manually list variable vars = c(\"NAME\", \"B19013_001E\", \"B19013_001EA\", \"B19013_001M\", \"B19013_001MA\"), using groups much easier.","code":"group_B19013 <- listCensusMetadata( name = \"acs/acs5\", vintage = 2022, type = \"variables\", group = \"B19013\") group_B19013 acs_income_group <- getCensus( name = \"acs/acs5\", vintage = 2022, vars = \"group(B19013)\", region = \"place:*\", regionin = \"state:01\") head(acs_income_group)"},{"path":"https://www.hrecht.com/censusapi/articles/getting-started.html","id":"advanced-geographies","dir":"Articles","previous_headings":"","what":"Advanced geographies","title":"Getting started with censusapi","text":"geographies, particularly Census tracts blocks, need specified within larger geographies like states counties. varies API endpoint, make sure read documentation specific API run listCensusMetadata(type = \"geographies\") see available options. Tract-level data 2010 Decennial Census can requested one state time. example, use built fips list state FIPS codes request tract-level data state join single data frame. regionin argument getCensus() can also used string nested geographies, shown . 2010 Decennial Census summary file 1 requires specify state county retrieve block-level data. Use region request block level data, regionin specify desired state county. many examples, frequently asked questions, troubleshooting, advanced topics check articles.","code":"tracts <- NULL for (f in fips) { stateget <- paste(\"state:\", f, sep=\"\") temp <- getCensus( name = \"dec/sf1\", vintage = 2010, vars = \"P001001\", region = \"tract:*\", regionin = stateget) tracts <- rbind(tracts, temp) } # How many tracts are present? nrow(tracts) #> [1] 73057 head(tracts) data2010 <- getCensus( name = \"dec/sf1\", vintage = 2010, vars = \"P001001\", region = \"block:*\", regionin = \"state:36+county:027+tract:010000\") head(data2010)"},{"path":"https://www.hrecht.com/censusapi/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Hannah Recht. Author, maintainer.","code":""},{"path":"https://www.hrecht.com/censusapi/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Recht H (2024). censusapi: Retrieve Data Census APIs. R package version 0.9.0.9000, https://github.com/hrecht/censusapi, https://www.hrecht.com/censusapi/.","code":"@Manual{, title = {censusapi: Retrieve Data from the Census APIs}, author = {Hannah Recht}, year = {2024}, note = {R package version 0.9.0.9000, https://github.com/hrecht/censusapi}, url = {https://www.hrecht.com/censusapi/}, }"},{"path":"https://www.hrecht.com/censusapi/index.html","id":"censusapi","dir":"","previous_headings":"","what":"Retrieve Data from the Census APIs","title":"Retrieve Data from the Census APIs","text":"censusapi lightweight package get data U.S. Census Bureau’s APIs. 1,500 API endpoints available, including data surveys Decennial Census, American Community Survey, International Trade Datasets, Small Area Health Insurance Estimates Economics Indicators Time Series. getCensus() lets users retrieves data datasets using simple, consistent syntax. package also includes metadata functions help users determine datasets available variable, geography, options .","code":""},{"path":"https://www.hrecht.com/censusapi/index.html","id":"installation","dir":"","previous_headings":"","what":"Installation","title":"Retrieve Data from the Census APIs","text":"Get latest stable release CRAN: can also install latest development version censusapi Github using devtools:","code":"install.packages(\"censusapi\") # Install the devtools package if needed # install.packages(\"devtools\") devtools::install_github(\"hrecht/censusapi\")"},{"path":"https://www.hrecht.com/censusapi/index.html","id":"basic-usage","dir":"","previous_headings":"","what":"Basic usage","title":"Retrieve Data from the Census APIs","text":"Using Small Area Income Poverty Estimates dataset, get poverty rate (SAEPOVRTALL_PT) every year since 2010 Los Angeles County, California. Using 2022 5-year American Community Survey Subject Tables dataset, Census tracts Arizona, get : total number households (S2801_C01_001E) number households without internet subscription (S2801_C01_019E) percent households without internet subscription (S2801_C02_019E) Census tract name","code":"poverty_rate <- getCensus( name = \"timeseries/poverty/saipe\", vars = c(\"NAME\", \"SAEPOVRTALL_PT\"), region = \"county:037\", regionin = \"state:06\", time = \"from 2010\") poverty_rate #> time state county NAME SAEPOVRTALL_PT #> 1 2010 06 037 Los Angeles County 17.6 #> 2 2011 06 037 Los Angeles County 18.4 #> 3 2012 06 037 Los Angeles County 19.1 #> 4 2013 06 037 Los Angeles County 19.0 #> 5 2014 06 037 Los Angeles County 18.7 #> 6 2015 06 037 Los Angeles County 16.7 #> 7 2016 06 037 Los Angeles County 16.3 #> 8 2017 06 037 Los Angeles County 14.9 #> 9 2018 06 037 Los Angeles County 14.2 #> 10 2019 06 037 Los Angeles County 13.4 #> 11 2020 06 037 Los Angeles County 13.2 #> 12 2021 06 037 Los Angeles County 14.1 #> 13 2022 06 037 Los Angeles County 13.9 no_internet <- getCensus( name = \"acs/acs5/subject\", vintage = 2022, vars = c(\"S2801_C01_001E\", \"S2801_C01_019E\", \"S2801_C02_019E\", \"NAME\"), region = \"tract:*\", regionin = \"state:04\") head(no_internet) #> state county tract S2801_C01_001E S2801_C01_019E S2801_C02_019E NAME #> 1 04 001 942600 429 412 96.0 Census Tract 9426; Apache County; Arizona #> 2 04 001 942700 1439 1006 69.9 Census Tract 9427; Apache County; Arizona #> 3 04 001 944000 1556 903 58.0 Census Tract 9440; Apache County; Arizona #> 4 04 001 944100 1446 966 66.8 Census Tract 9441; Apache County; Arizona #> 5 04 001 944201 1154 835 72.4 Census Tract 9442.01; Apache County; Arizona #> 6 04 001 944202 1111 874 78.7 Census Tract 9442.02; Apache County; Arizona"},{"path":"https://www.hrecht.com/censusapi/index.html","id":"advanced-usage","dir":"","previous_headings":"","what":"Advanced usage","title":"Retrieve Data from the Census APIs","text":"Users can pass valid parameters APIs using getCensus(). Census Bureau refers filterable parameter variables “predicates”. Using Small Area Health Insurance Estimates, can use predicates get uninsured rate (PCTUI_PT) specific demographic groups, including income group, age group, race/ethnicity. learn using censusapi, read package documentation articles https://www.hrecht.com/censusapi/.","code":"# See the values of `IPRCAT` listCensusMetadata( name = \"timeseries/healthins/sahie\", type = \"values\", variable = \"IPRCAT\") #> code label #> 1 0 All Incomes #> 2 1 Less than or Equal to 200% of Poverty #> 3 2 Less than or Equal to 250% of Poverty #> 4 3 Less than or Equal to 138% of Poverty #> 5 4 Less than or Equal to 400% of Poverty #> 6 5 138% to 400% Poverty # See the values of `AGECAT` listCensusMetadata( name = \"timeseries/healthins/sahie\", type = \"values\", variable = \"AGECAT\") #> code label #> 1 0 Under 65 years #> 2 1 18 to 64 #> 3 2 40 to 64 #> 4 3 50 to 64 #> 5 4 Under 19 years #> 6 5 21 to 64 years # Get the uninsured rate over time for for nonelderly adults (AGECAT = 1) # at 138% to 400% of the federal poverty line (IPRCAT = 5) # in Los Angeles County, California sahie_la <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"PCTUI_PT\"), region = \"county:037\", regionin = \"state:06\", time = \"from 2012\", IPRCAT = 5, AGECAT = 1) sahie_la #> time state county NAME PCTUI_PT IPRCAT AGECAT #> 1 2012 06 037 Los Angeles County, CA 35.5 5 1 #> 2 2013 06 037 Los Angeles County, CA 34.3 5 1 #> 3 2014 06 037 Los Angeles County, CA 25.0 5 1 #> 4 2015 06 037 Los Angeles County, CA 18.6 5 1 #> 5 2016 06 037 Los Angeles County, CA 16.3 5 1 #> 6 2017 06 037 Los Angeles County, CA 15.5 5 1 #> 7 2018 06 037 Los Angeles County, CA 16.2 5 1 #> 8 2019 06 037 Los Angeles County, CA 18.3 5 1 #> 9 2020 06 037 Los Angeles County, CA 16.7 5 1 #> 10 2021 06 037 Los Angeles County, CA 16.1 5 1 # Get the 2021 uninsured rate for nonelderly adults (AGECAT = 1) # at 138% to 400% of the federal poverty line (IPRCAT = 5) # by race and ethnicity for Alabama sahie_alabama <- getCensus( name = \"timeseries/healthins/sahie\", vars = c(\"NAME\", \"PCTUI_PT\", \"RACECAT\", \"RACE_DESC\"), region = \"state:*\", time = 2021, IPRCAT = 5, AGECAT = 1) sahie_alabama #> time state NAME PCTUI_PT RACECAT RACE_DESC IPRCAT AGECAT #> 1 2021 01 Alabama 15.9 0 All Races 5 1 #> 2 2021 01 Alabama 14.1 1 White alone, not Hispanic or Latino 5 1 #> 3 2021 01 Alabama 15.4 2 Black or African American alone, not Hispanic or Latino 5 1 #> 4 2021 01 Alabama 40.4 3 Hispanic or Latino (any race) 5 1 #> 5 2021 01 Alabama 20.8 4 American Indian and Alaska Native alone, not Hispanic or Latino 5 1 #> 6 2021 01 Alabama 14.8 5 Asian alone, not Hispanic or Latino 5 1 #> 7 2021 01 Alabama 20.0 6 Native Hawaiian and Other Pacific Islander alone, not Hispanic or Latino 5 1 #> 8 2021 01 Alabama 16.9 7 Two or More Races, not Hispanic or Latino 5 1"},{"path":"https://www.hrecht.com/censusapi/index.html","id":"disclaimer","dir":"","previous_headings":"","what":"Disclaimer","title":"Retrieve Data from the Census APIs","text":"product uses Census Bureau Data API endorsed certified Census Bureau. Please note project released Contributor Code Conduct. participating project agree abide terms.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/fips.html","id":null,"dir":"Reference","previous_headings":"","what":"List of state fips codes - 50 states plus DC — fips","title":"List of state fips codes - 50 states plus DC — fips","text":"small geographies Census APIs can used state hierarchy. list fips codes may looped retrieve data states.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/fips.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"List of state fips codes - 50 states plus DC — fips","text":"","code":"fips"},{"path":"https://www.hrecht.com/censusapi/reference/fips.html","id":"format","dir":"Reference","previous_headings":"","what":"Format","title":"List of state fips codes - 50 states plus DC — fips","text":"list fips codes 50 states District Columbia.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/fips.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"List of state fips codes - 50 states plus DC — fips","text":"","code":"fips #> [1] \"01\" \"02\" \"04\" \"05\" \"06\" \"08\" \"09\" \"10\" \"11\" \"12\" \"13\" \"15\" \"16\" \"17\" \"18\" #> [16] \"19\" \"20\" \"21\" \"22\" \"23\" \"24\" \"25\" \"26\" \"27\" \"28\" \"29\" \"30\" \"31\" \"32\" \"33\" #> [31] \"34\" \"35\" \"36\" \"37\" \"38\" \"39\" \"40\" \"41\" \"42\" \"44\" \"45\" \"46\" \"47\" \"48\" \"49\" #> [46] \"50\" \"51\" \"53\" \"54\" \"55\" \"56\""},{"path":"https://www.hrecht.com/censusapi/reference/getCensus.html","id":null,"dir":"Reference","previous_headings":"","what":"Retrieve Census data from a given API — getCensus","title":"Retrieve Census data from a given API — getCensus","text":"Retrieve Census data given API","code":""},{"path":"https://www.hrecht.com/censusapi/reference/getCensus.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Retrieve Census data from a given API — getCensus","text":"","code":"getCensus( name, vintage = NULL, key = NULL, vars, region = NULL, regionin = NULL, time = NULL, show_call = FALSE, convert_variables = TRUE, year = NULL, date = NULL, period = NULL, monthly = NULL, category_code = NULL, data_type_code = NULL, naics = NULL, pscode = NULL, naics2012 = NULL, naics2007 = NULL, naics2002 = NULL, naics1997 = NULL, sic = NULL, ... )"},{"path":"https://www.hrecht.com/censusapi/reference/getCensus.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Retrieve Census data from a given API — getCensus","text":"name programmatic name dataset, e.g. \"timeseries/poverty/saipe\" \"acs/acs5\". Use listCensusApis() see valid dataset names. Required. vintage Vintage (year) dataset, e.g. 2014. required timeseries APIs. key Census API key, obtained https://api.census.gov/data/key_signup.html. CENSUS_KEY CENSUS_API_KEY stored .Renviron file, getCensus() automatically use key. Using key recommended required. vars List variables get. Required. region Geography get. regionin Optional hierarchical geography limit region. time Time period data get. Required timeseries APIs. show_call Display underlying API call sent Census Bureau. Default FALSE. convert_variables Convert columns likely numbers numeric data. Default TRUE. false, columns characters, type returned Census Bureau. year, date, period, monthly, category_code, data_type_code, naics, pscode, naics2012, naics2007, naics2002, naics1997, sic Optional arguments used timeseries data APIs. ... valid arguments pass Census API. Note: APIs case sensitive.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/getCensus.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Retrieve Census data from a given API — getCensus","text":"data frame results specified U.S. Census Bureau dataset.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/getCensus.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Retrieve Census data from a given API — getCensus","text":"","code":"# Get total population and median household income for Census places # (cities, towns, villages) in a single state from the 5-year American Community Survey. acs_simple <- getCensus( name = \"acs/acs5\", vintage = 2022, vars = c(\"NAME\", \"B01001_001E\", \"B19013_001E\"), region = \"place:*\", regionin = \"state:01\") head(acs_simple) #> state place NAME B01001_001E B19013_001E #> 1 01 00100 Abanda CDP, Alabama 335 29263 #> 2 01 00124 Abbeville city, Alabama 2309 35147 #> 3 01 00460 Adamsville city, Alabama 4325 58631 #> 4 01 00484 Addison town, Alabama 665 47188 #> 5 01 00676 Akron town, Alabama 310 53929 #> 6 01 00820 Alabaster city, Alabama 33417 89423 # Get all data from the B08301 variable group, \"Means of Transportation to Work.\" # This returns estimates as well as margins of error and annotation flags. acs_group <- getCensus( name = \"acs/acs5\", vintage = 2022, vars = \"group(B08301)\", region = \"state:*\") head(acs_group) #> state B08301_001E B08301_001EA B08301_001M B08301_001MA B08301_002E #> 1 01 2183677 9550 1985736 #> 2 02 351067 2187 274263 #> 3 04 3244419 9451 2610395 #> 4 05 1304084 6929 1177402 #> 5 06 18353469 22043 14313290 #> 6 08 3006848 8149 2304559 #> B08301_002EA B08301_002M B08301_002MA B08301_003E B08301_003EA B08301_003M #> 1 10017 1808631 9646 #> 2 2820 231484 3143 #> 3 12006 2285920 12162 #> 4 6616 1051964 6428 #> 5 23546 12561068 25223 #> 6 9026 2062480 8986 #> B08301_003MA B08301_004E B08301_004EA B08301_004M B08301_004MA B08301_005E #> 1 177105 4751 137578 #> 2 42779 2105 32397 #> 3 324475 5200 242556 #> 4 125438 3531 94684 #> 5 1752222 14058 1269237 #> 6 242079 5338 180493 #> B08301_005EA B08301_005M B08301_005MA B08301_006E B08301_006EA B08301_006M #> 1 4204 24358 1675 #> 2 1886 5712 684 #> 3 4612 48889 1844 #> 4 2975 18415 1284 #> 5 10568 281935 5811 #> 6 4522 37353 1984 #> B08301_006MA B08301_007E B08301_007EA B08301_007M B08301_007MA B08301_008E #> 1 8791 1005 2998 #> 2 2977 646 1039 #> 3 18286 1327 10171 #> 4 7226 913 2976 #> 5 109445 3668 61640 #> 6 14757 1317 6621 #> B08301_008EA B08301_008M B08301_008MA B08301_009E B08301_009EA B08301_009M #> 1 551 3380 602 #> 2 255 654 256 #> 3 1062 4573 689 #> 4 636 2137 354 #> 5 2554 29965 1345 #> 6 758 2855 496 #> B08301_009MA B08301_010E B08301_010EA B08301_010M B08301_010MA B08301_011E #> 1 6982 910 6523 #> 2 3805 603 3415 #> 3 40113 2078 35607 #> 4 3744 551 3387 #> 5 662772 7190 423288 #> 6 63953 2586 45745 #> B08301_011EA B08301_011M B08301_011MA B08301_012E B08301_012EA B08301_012M #> 1 928 122 117 #> 2 577 1 3 #> 3 1989 960 238 #> 4 494 114 97 #> 5 5639 140862 3435 #> 6 2229 4035 418 #> B08301_012MA B08301_013E B08301_013EA B08301_013M B08301_013MA B08301_014E #> 1 77 55 73 #> 2 15 23 14 #> 3 471 198 2692 #> 4 2 5 59 #> 5 58487 2233 28260 #> 6 2546 416 11234 #> B08301_014EA B08301_014M B08301_014MA B08301_015E B08301_015EA B08301_015M #> 1 95 187 100 #> 2 15 360 176 #> 3 455 383 143 #> 4 51 182 170 #> 5 1506 11875 985 #> 6 864 393 164 #> B08301_015MA B08301_016E B08301_016EA B08301_016M B08301_016MA B08301_017E #> 1 1253 321 1878 #> 2 1599 368 474 #> 3 6508 836 10036 #> 4 603 202 1278 #> 5 37588 1610 46193 #> 6 2955 510 4587 #> B08301_017EA B08301_017M B08301_017MA B08301_018E B08301_018EA B08301_018M #> 1 307 1805 302 #> 2 127 2447 414 #> 3 824 19629 1240 #> 4 269 2052 380 #> 5 1803 135240 3079 #> 6 503 30681 1435 #> B08301_018MA B08301_019E B08301_019EA B08301_019M B08301_019MA B08301_020E #> 1 24058 1737 16559 #> 2 27039 1177 13159 #> 3 54751 2254 40263 #> 4 19571 1110 11443 #> 5 437430 5563 220114 #> 6 79574 2429 24630 #> B08301_020EA B08301_020M B08301_020MA B08301_021E B08301_021EA B08301_021M #> 1 1341 145406 4523 #> 2 672 28281 1635 #> 3 2081 462724 7442 #> 4 1050 87991 2781 #> 5 4380 2500842 15830 #> 6 1187 495909 6033 #> B08301_021MA GEO_ID NAME #> 1 0400000US01 Alabama #> 2 0400000US02 Alaska #> 3 0400000US04 Arizona #> 4 0400000US05 Arkansas #> 5 0400000US06 California #> 6 0400000US08 Colorado # Retreive 2020 Decennial Census block group data within a specific Census tract, # using the regionin argument to precisely specify the Census tract, county, # and state. decennial_block_group <- getCensus( name = \"dec/dhc\", vintage = 2020, vars = c(\"NAME\", \"P1_001N\"), region = \"block group:*\", regionin = \"state:36+county:027+tract:220300\") head(decennial_block_group) #> state county tract block_group #> 1 36 027 220300 1 #> 2 36 027 220300 2 #> 3 36 027 220300 3 #> 4 36 027 220300 4 #> NAME P1_001N #> 1 Block Group 1; Census Tract 2203; Dutchess County; New York 1467 #> 2 Block Group 2; Census Tract 2203; Dutchess County; New York 1394 #> 3 Block Group 3; Census Tract 2203; Dutchess County; New York 1192 #> 4 Block Group 4; Census Tract 2203; Dutchess County; New York 885 # Get poverty rates for children and for people of all ages beginning in 2000 using the # Small Area Income and Poverty Estimates API saipe <- getCensus( name = \"timeseries/poverty/saipe\", vars = c(\"NAME\", \"SAEPOVRT0_17_PT\", \"SAEPOVRTALL_PT\"), region = \"state:01\", time = \"from 2000\") head(saipe) #> time state NAME SAEPOVRT0_17_PT SAEPOVRTALL_PT #> 1 2000 01 Alabama 20.5 14.6 #> 2 2001 01 Alabama 22.1 15.7 #> 3 2002 01 Alabama 21.6 15.4 #> 4 2003 01 Alabama 22.3 15.3 #> 5 2004 01 Alabama 22.6 16.1 #> 6 2005 01 Alabama 24.3 16.9 # Get the number of employees and number of establishments in the construction sector, # NAICS2017 code 23, using the County Business Patterns API cbp <- getCensus( name = \"cbp\", vintage = 2021, vars = c(\"EMP\", \"ESTAB\", \"NAICS2017_LABEL\"), region = \"county:*\", NAICS2017 = 23) head(cbp) #> state county EMP ESTAB NAICS2017_LABEL NAICS2017 #> 1 01 001 507 90 Construction 23 #> 2 01 003 4322 705 Construction 23 #> 3 01 005 75 20 Construction 23 #> 4 01 007 654 25 Construction 23 #> 5 01 009 592 118 Construction 23 #> 6 01 011 50 8 Construction 23"},{"path":"https://www.hrecht.com/censusapi/reference/getFunction.html","id":null,"dir":"Reference","previous_headings":"","what":"Internal function: Get the API response, return a data frame — getFunction","title":"Internal function: Get the API response, return a data frame — getFunction","text":"Internal function: Get API response, return data frame","code":""},{"path":"https://www.hrecht.com/censusapi/reference/getFunction.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Internal function: Get the API response, return a data frame — getFunction","text":"","code":"getFunction( apiurl, name, key, get, region, regionin, time, show_call, convert_variables, year, date, period, monthly, category_code, data_type_code, naics, pscode, naics2012, naics2007, naics2002, naics1997, sic, ... )"},{"path":"https://www.hrecht.com/censusapi/reference/get_api_key.html","id":null,"dir":"Reference","previous_headings":"","what":"Retrieve a Census API key stored the .Renivron file — get_api_key","title":"Retrieve a Census API key stored the .Renivron file — get_api_key","text":"Retrieve Census API key stored .Renivron file","code":""},{"path":"https://www.hrecht.com/censusapi/reference/get_api_key.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Retrieve a Census API key stored the .Renivron file — get_api_key","text":"","code":"get_api_key()"},{"path":"https://www.hrecht.com/censusapi/reference/get_api_key.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Retrieve a Census API key stored the .Renivron file — get_api_key","text":"CENSUS_KEY CENSUS_API_KEY string stored user's .Renviron. file, warning message printed per R session none found.","code":""},{"path":[]},{"path":"https://www.hrecht.com/censusapi/reference/get_api_key.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Retrieve a Census API key stored the .Renivron file — get_api_key","text":"","code":"if (FALSE) { get_api_key() }"},{"path":"https://www.hrecht.com/censusapi/reference/has_api_key.html","id":null,"dir":"Reference","previous_headings":"","what":"Is there a saved Census API key in the .Renivron file? — has_api_key","title":"Is there a saved Census API key in the .Renivron file? — has_api_key","text":"saved Census API key .Renivron file?","code":""},{"path":"https://www.hrecht.com/censusapi/reference/has_api_key.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Is there a saved Census API key in the .Renivron file? — has_api_key","text":"","code":"has_api_key()"},{"path":"https://www.hrecht.com/censusapi/reference/has_api_key.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Is there a saved Census API key in the .Renivron file? — has_api_key","text":"TRUE FALSE.","code":""},{"path":[]},{"path":"https://www.hrecht.com/censusapi/reference/has_api_key.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Is there a saved Census API key in the .Renivron file? — has_api_key","text":"","code":"has_api_key() #> [1] TRUE"},{"path":"https://www.hrecht.com/censusapi/reference/listCensusApis.html","id":null,"dir":"Reference","previous_headings":"","what":"Get general information about available datasets — listCensusApis","title":"Get general information about available datasets — listCensusApis","text":"Scrapes https://api.census.gov/data.json returns dataframe includes columns dataset title, description, name, vintage, url, dataset type, useful fields.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/listCensusApis.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get general information about available datasets — listCensusApis","text":"","code":"listCensusApis(name = NULL, vintage = NULL)"},{"path":"https://www.hrecht.com/censusapi/reference/listCensusApis.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get general information about available datasets — listCensusApis","text":"name Optional complete partial API dataset programmatic name. example, \"acs\", \"acs/acs5\", \"acs/acs5/subject\". using partial name, needs left-part dataset name /, e.g. \"timeseries/eits\" \"dec\" \"acs/acs5\". vintage Optional vintage (year) dataset.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/listCensusApis.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get general information about available datasets — listCensusApis","text":"data frame following columns: title: Short written description dataset. name: Programmatic name dataset. vintage: Year survey, use microdata aggregate datasets. type: Dataset type, either \"Aggregate\", \"Microdata\", \"Timeseries\". temporal: Time period dataset. Warning: always documented. spatial: Spatial region dataset. Warning: always documented. url: Base URL dataset endpoint. modified: Date last modified. Warning: sometimes date. description: Long written description dataset. contact: Email address specific questions Census Bureau survey.","code":""},{"path":[]},{"path":"https://www.hrecht.com/censusapi/reference/listCensusApis.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get general information about available datasets — listCensusApis","text":"","code":"# Get information about every dataset available in the APIs apis <- listCensusApis() head(apis) #> title name #> 1 Current Population Survey: Basic Monthly cps/basic/feb #> 2 Current Population Survey: Basic Monthly cps/basic/jan #> 3 Current Population Survey Annual Social and Economic Supplement cps/asec/mar #> 4 Current Population Survey: Basic Monthly cps/basic/apr #> 5 Current Population Survey: Basic Monthly cps/basic/aug #> 6 Current Population Survey: Basic Monthly cps/basic/dec #> vintage type temporal spatial #> 1 2024 Microdata 2024-02/2024-02 United States #> 2 2024 Microdata 2024-01/2024-01 United States #> 3 2023 Microdata 2023-03/2023-03 United States #> 4 2023 Microdata 2023-04/2023-04 United States #> 5 2023 Microdata 2023-08/2023-08 United States #> 6 2023 Microdata 2023-12/2023-12 United States #> url modified #> 1 http://api.census.gov/data/2024/cps/basic/feb 2024-01-11 15:35:41.0 #> 2 http://api.census.gov/data/2024/cps/basic/jan 2024-01-11 15:35:41.0 #> 3 http://api.census.gov/data/2023/cps/asec/mar 2023-08-14 09:09:01.0 #> 4 http://api.census.gov/data/2023/cps/basic/apr 2023-01-10 15:11:40.0 #> 5 http://api.census.gov/data/2023/cps/basic/aug 2023-01-10 15:11:40.0 #> 6 http://api.census.gov/data/2023/cps/basic/dec 2023-01-10 15:11:40.0 #> description #> 1 To provide estimates of employment, unemployment, and other characteristics of the general labor force, of the population as a whole, and of various subgroups of the population. Monthly labor force data for the country are used by the Bureau of Labor Statistics (BLS) to determine the distribution of funds under the Job Training Partnership Act. These data are collected through combined computer-assisted personal interviewing (CAPI) and computer-assisted telephone interviewing (CATI). In addition to the labor force data, the CPS basic funding provides annual data on work experience, income, health insurance, and migration data from the Annual Social and Economic Supplement (ASEC), and on school enrollment of the population from the October Supplement. Other supplements, some of which are sponsored by other agencies, are conducted biennially or intermittently. #> 2 To provide estimates of employment, unemployment, and other characteristics of the general labor force, of the population as a whole, and of various subgroups of the population. Monthly labor force data for the country are used by the Bureau of Labor Statistics (BLS) to determine the distribution of funds under the Job Training Partnership Act. These data are collected through combined computer-assisted personal interviewing (CAPI) and computer-assisted telephone interviewing (CATI). In addition to the labor force data, the CPS basic funding provides annual data on work experience, income, health insurance, and migration data from the Annual Social and Economic Supplement (ASEC), and on school enrollment of the population from the October Supplement. Other supplements, some of which are sponsored by other agencies, are conducted biennially or intermittently. #> 3 The Annual Social and Economic Supplement or March CPS supplement is the primary source of detailed information on income and work experience in the United States. Numerous publications based on this survey are issued each year by the Bureaus of Labor Statistics and Census. A public-use microdata file is available for private researchers, who also produce many academic and policy-related documents based on these data. The Annual Social and Economic Supplement is used to generate the annual Population Profile of the United States, reports on geographical mobility and educational attainment, and detailed analysis of money income and poverty status. The labor force and work experience data from this survey are used to profile the U.S. labor market and to make employment projections. To allow for the same type of in-depth analysis of hispanics, additional hispanic sample units are added to the basic CPS sample in March each year. Additional weighting is also performed so that estimates can be made for households and families, in addition to persons. #> 4 To provide estimates of employment, unemployment, and other characteristics of the general labor force, of the population as a whole, and of various subgroups of the population. Monthly labor force data for the country are used by the Bureau of Labor Statistics (BLS to determine the distribution of funds under the Job Training Partnership Act. These data are collected through combined computer-assisted personal interviewing (CAPI) and computer-assisted telephone interviewing (CATI). In addition to the labor force data, the CPS basic funding provides annual data on work experience, income, health insurance, and migration data from the Annual Social and Economic Supplement (ASEC), and on school enrollment of the population from the October Supplement. Other supplements, some of which are sponsored by other agencies, are conducted biennially or intermittently. #> 5 To provide estimates of employment, unemployment, and other characteristics of the general labor force, of the population as a whole, and of various subgroups of the population. Monthly labor force data for the country are used by the Bureau of Labor Statistics (BLS to determine the distribution of funds under the Job Training Partnership Act. These data are collected through combined computer-assisted personal interviewing (CAPI) and computer-assisted telephone interviewing (CATI). In addition to the labor force data, the CPS basic funding provides annual data on work experience, income, health insurance, and migration data from the Annual Social and Economic Supplement (ASEC), and on school enrollment of the population from the October Supplement. Other supplements, some of which are sponsored by other agencies, are conducted biennially or intermittently. #> 6 To provide estimates of employment, unemployment, and other characteristics of the general labor force, of the population as a whole, and of various subgroups of the population. Monthly labor force data for the country are used by the Bureau of Labor Statistics (BLS) to determine the distribution of funds under the Job Training Partnership Act. These data are collected through combined computer-assisted personal interviewing (CAPI) and computer-assisted telephone interviewing (CATI). In addition to the labor force data, the CPS basic funding provides annual data on work experience, income, health insurance, and migration data from the Annual Social and Economic Supplement (ASEC), and on school enrollment of the population from the October Supplement. Other supplements, some of which are sponsored by other agencies, are conducted biennially or intermittently. #> contact #> 1 dsd.cps@census.gov #> 2 dsd.cps@census.gov #> 3 dsd.cps@census.gov #> 4 dsd.cps@census.gov #> 5 dsd.cps@census.gov #> 6 dsd.cps@census.gov # Get information about all vintage 2022 datasets apis_2022 <- listCensusApis(vintage = 2022) head(apis_2022) #> title #> 1 American Community Survey: 1-Year Estimates: Detailed Tables 1-Year #> 2 American Community Survey: 1-Year Estimates: Comparison Profiles 1-Year #> 3 American Community Survey: 1-Year Estimates: Data Profiles 1-Year #> 4 2022 American Community Survey: 1-Year Estimates - Public Use Microdata Sample #> 5 2022 American Community Survey: 1-Year Estimates - Public Use Microdata Sample Puerto Rico #> 6 American Community Survey: 1-Year Estimates: Selected Population Profiles 1-Year #> name vintage type temporal spatial #> 1 acs/acs1 2022 Aggregate 2022/2022 US #> 2 acs/acs1/cprofile 2022 Aggregate 2022/2022 US #> 3 acs/acs1/profile 2022 Aggregate 2022/2022 US #> 4 acs/acs1/pums 2022 Microdata 2022/2022 US #> 5 acs/acs1/pumspr 2022 Microdata 2022/2022 Puerto Rico #> 6 acs/acs1/spp 2022 Aggregate 2022/2022 US #> url modified #> 1 http://api.census.gov/data/2022/acs/acs1 2023-04-24 14:51:53.0 #> 2 http://api.census.gov/data/2022/acs/acs1/cprofile 2023-04-24 14:49:08.0 #> 3 http://api.census.gov/data/2022/acs/acs1/profile 2023-04-24 14:49:41.0 #> 4 http://api.census.gov/data/2022/acs/acs1/pums 2023-06-08 10:03:42.0 #> 5 http://api.census.gov/data/2022/acs/acs1/pumspr 2023-06-08 10:03:09.0 #> 6 http://api.census.gov/data/2022/acs/acs1/spp 2023-04-24 14:51:20.0 #> description #> 1 The American Community Survey (ACS) is an ongoing survey that provides data every year -- giving communities the current information they need to plan investments and services. The ACS covers a broad range of topics about social, economic, demographic, and housing characteristics of the U.S. population. Much of the ACS data provided on the Census Bureau's Web site are available separately by age group, race, Hispanic origin, and sex. Summary files, Subject tables, Data profiles, and Comparison profiles are available for the nation, all 50 states, the District of Columbia, Puerto Rico, every congressional district, every metropolitan area, and all counties and places with populations of 65,000 or more. Detailed Tables contain the most detailed cross-tabulations published for areas 65k and more. The data are population counts. There are over 31,000 variables in this dataset. #> 2 The American Community Survey (ACS) is an ongoing survey that provides data every year -- giving communities the current information they need to plan investments and services. The ACS covers a broad range of topics about social, economic, demographic, and housing characteristics of the U.S. population. Much of the ACS data provided on the Census Bureau's Web site are available separately by age group, race, Hispanic origin, and sex. Summary files, Subject tables, Data profiles, and Comparison profiles are available for the nation, all 50 states, the District of Columbia, Puerto Rico, every congressional district, every metropolitan area, and all counties and places with populations of 65,000 or more. Comparison profiles are similar to Data profiles but also include comparisons with past-year data. The current year data are compared with each of the last four years of data and include statistical significance testing. There are over 1,000 variables in this dataset. #> 3 The American Community Survey (ACS) is a US-wide survey designed to provide communities a fresh look at how they are changing. The ACS replaced the decennial census long form in 2010 and thereafter by collecting long form type information throughout the decade rather than only once every 10 years. Questionnaires are mailed to a sample of addresses to obtain information about households -- that is, about each person and the housing unit itself. The American Community Survey produces demographic, social, housing and economic estimates in the form of 1 and 5-year estimates based on population thresholds. The strength of the ACS is in estimating population and housing characteristics. The data profiles provide key estimates for each of the topic areas covered by the ACS for the us, all 50 states, the District of Columbia, Puerto Rico, every congressional district, every metropolitan area, and all counties and places with populations of 65,000 or more. Although the ACS produces population, demographic and housing unit estimates, it is the Census Bureau's Population Estimates Program that produces and disseminates the official estimates of the population for the US, states, counties, cities and towns, and estimates of housing units for states and counties. For 2010 and other decennial census years, the Decennial Census provides the official counts of population and housing units. #> 4 The American Community Survey (ACS) Public Use Microdata Sample (PUMS) contains a sample of responses to the ACS. The ACS PUMS dataset includes variables for nearly every question on the survey, as well as many new variables that were derived after the fact from multiple survey responses (such as poverty status). Each record in the file represents a single person, or, in the household-level dataset, a single housing unit. In the person-level file, individuals are organized into households, making possible the study of people within the contexts of their families and other household members. Individuals living in Group Quarters, such as nursing facilities or college facilities, are also included on the person file. ACS PUMS data are available at the nation, state, and Public Use Microdata Area (PUMA) levels. PUMAs are special non-overlapping areas that partition each state into contiguous geographic units containing roughly 100,000 people each. ACS PUMS files for an individual year, such as 2022, contain data on approximately one percent of the United States population. #> 5 The Public Use Microdata Sample (PUMS) for Puerto Rico (PR) contains a sample of responses to the Puerto Rico Community Survey (PRCS). The PRCS is similar to, but separate from, the American Community Survey (ACS). The PRCS collects data about the population and housing units in Puerto Rico. Puerto Rico data is not included in the national PUMS files. It is published as a state equivalent file and has a State FIPS code of \"72\". The file includes variables for nearly every question on the survey, as well as many new variables that were derived after the fact from multiple survey responses (such as poverty status). Each record in the file represents a single person, or, in the household-level dataset, a single housing unit. In the person-level file, individuals are organized into households, making possible the study of people within the contexts of their families and other household members. Individuals living in Group Quarters, such as nursing facilities or college facilities, are also included on the person file. Data are available at the state and Public Use Microdata Area (PUMA) levels. PUMAs are special non-overlapping areas that partition Puerto Rico into contiguous geographic units containing roughly 100,000 people each. The Puerto Rico PUMS file for an individual year, such as 2022, contain data on approximately one percent of the Puerto Rico population. #> 6 Selected Population Profiles provide broad social, economic, and housing profiles for a large number of race, ethnic, ancestry, and country/region of birth groups. The data are presented as population counts for the total population and various subgroups and percentages. #> contact #> 1 acso.users.support@census.gov #> 2 acso.users.support@census.gov #> 3 acso.users.support@census.gov #> 4 acso.users.support@census.gov #> 5 acso.users.support@census.gov #> 6 acso.users.support@census.gov # Get information about all timeseries datasets apis_timeseries <- listCensusApis(name = \"timeseries\") head(apis_timeseries) #> title #> 1 Annual Economic Surveys: Annual Survey of Manufactures Area #> 2 Economic Surveys: Annual Survey of Manufactures: Annual Survey of Manufactures Area #> 3 Annual Economic Surveys: Annual Survey of Manufactures Benchmark 2017 #> 4 Time Series Annual Survey of Manufactures: Statistics for Industry Groups and Industries #> 5 Time Series Annual Survey of Manufactures: Value of Shipments for Product Classes #> 6 Time Series Annual Survey of Manufactures: Statistics for All Manufacturing by State #> name type temporal spatial #> 1 timeseries/asm/area2012 Timeseries #> 2 timeseries/asm/area2017 Timeseries 2018/2021 United States #> 3 timeseries/asm/benchmark2017 Timeseries #> 4 timeseries/asm/industry Timeseries United States #> 5 timeseries/asm/product Timeseries United States #> 6 timeseries/asm/state Timeseries United States #> url modified #> 1 http://api.census.gov/data/timeseries/asm/area2012 2018-12-13 00:00:00.0 #> 2 http://api.census.gov/data/timeseries/asm/area2017 2020-03-17 00:00:00.0 #> 3 http://api.census.gov/data/timeseries/asm/benchmark2017 2021-03-17 00:00:00.0 #> 4 http://api.census.gov/data/timeseries/asm/industry 2018-06-29 #> 5 http://api.census.gov/data/timeseries/asm/product 2017-12-15 #> 6 http://api.census.gov/data/timeseries/asm/state 2017-12-15 #> description #> 1 The Annual Survey of Manufactures (ASM) provides key intercensal measures of manufacturing activity, products, and location for the public and private sectors. The ASM provides the best current measure of current U.S. manufacturing industry outputs, inputs, and operating status, and is the primary basis for updates of the Longitudinal Research Database (LRD). Census Bureau staff and academic researchers with sworn agent status use the LRD for micro data analysis. #> 2 The Annual Survey of Manufactures (ASM) provides key intercensal measures of manufacturing activity, products, and location for the public and private sectors. The ASM provides the best current measure of current U.S. manufacturing industry outputs, inputs, and operating status, and is the primary basis for updates of the Longitudinal Research Database (LRD). Census Bureau staff and academic researchers with sworn agent status use the LRD for micro data analysis. #> 3 The Annual Survey of Manufactures (ASM) Benchmark provides key intercensal measures of manufacturing activity and products for the public and private sectors for four years following the Economic Census of Manufacturing. These benchmark tables present manufacturing establishment statistics from the 2013-2016 Annual Survey of Manufactures (ASM). The ASM Benchmark provides statistics on employment, payroll, worker hours, cost of materials, value added by manufacturing, inventories, and estimates for value of shipments for product classes of products manufactured as defined by the North American Industry Classification System. The ASM provides the best current measure of current U.S. manufacturing industry outputs, inputs, and operating status, and is the primary basis for updates of the Longitudinal Research Database (LRD). Census Bureau staff and academic researchers with sworn agent status use the LRD for micro data analysis. #> 4 The Annual Survey of Manufactures (ASM) provides key intercensal measures of manufacturing activity, products, and location for the public and private sectors. The ASM provides the best current measure of current U.S. manufacturing industry outputs, inputs, and operating status, and is the primary basis for updates of the Longitudinal Research Database (LRD). Census Bureau staff and academic researchers with sworn agent status use the LRD for micro data analysis. #> 5 The Annual Survey of Manufactures (ASM) provides key intercensal measures of manufacturing activity, products, and location for the public and private sectors. The ASM provides the best current measure of current U.S. manufacturing industry outputs, inputs, and operating status, and is the primary basis for updates of the Longitudinal Research Database (LRD). Census Bureau staff and academic researchers with sworn agent status use the LRD for micro data analysis. #> 6 The Annual Survey of Manufactures (ASM) provides key intercensal measures of manufacturing activity, products, and location for the public and private sectors. The ASM provides the best current measure of current U.S. manufacturing industry outputs, inputs, and operating status, and is the primary basis for updates of the Longitudinal Research Database (LRD). Census Bureau staff and academic researchers with sworn agent status use the LRD for micro data analysis. #> contact #> 1 Ewd.outreach@census.gov #> 2 ewd.outreach@census.gov #> 3 Ewd.outreach@census.gov #> 4 econ.dissemination@census.gov #> 5 stephen.c.mangum@census.gov #> 6 stephen.c.mangum@census.gov # Get information about 2020 Decennial Census datasets apis_decennial_2020 <- listCensusApis(name = \"dec\", vintage = 2020) head(apis_decennial_2020) #> title #> 1 Decennial Census: 118th Congressional District Summary File #> 2 Decennial Census of Island Areas: American Samoa Detailed Crosstabulations #> 3 Decennial Census of Island Areas: Guam Detailed Crosstabulations #> 4 Decennial Census of Island Areas: Commonwealth of the Northern Mariana Islands Detailed Crosstabulations #> 5 Decennial Census of Island Areas: U.S. Virgin Islands Detailed Crosstabulations #> 6 Decennial Census: Detailed Demographic and Housing Characteristics File A #> name vintage type temporal spatial #> 1 dec/cd118 2020 Aggregate 2020/2020 US #> 2 dec/crosstabas 2020 Aggregate 2020/2020 American Samoa #> 3 dec/crosstabgu 2020 Aggregate 2020/2020 Guam #> 4 dec/crosstabmp 2020 Aggregate 2020/2020 Northern Mariana Islands #> 5 dec/crosstabvi 2020 Aggregate 2020/2020 U.S. Virgin Islands #> 6 dec/ddhca 2020 Aggregate 2020/2020 United States #> url modified #> 1 http://api.census.gov/data/2020/dec/cd118 2022-10-25 00:00:00.0 #> 2 http://api.census.gov/data/2020/dec/crosstabas 2023-05-09 10:44:24.0 #> 3 http://api.census.gov/data/2020/dec/crosstabgu 2023-05-09 10:46:02.0 #> 4 http://api.census.gov/data/2020/dec/crosstabmp 2023-05-09 10:45:29.0 #> 5 http://api.census.gov/data/2020/dec/crosstabvi 2023-05-09 10:44:57.0 #> 6 http://api.census.gov/data/2020/dec/ddhca 2022-09-09 00:00:00.0 #> description #> 1 The Congressional District Summary File (118th Congress) (CD118) contains the data compiled from the questions asked of all people and about every housing unit in the 2020 Census. This product retabulates selected summary levels from the Demographic and Housing Characteristics File (DHC) for the 118th Congress and 2022 state legislative districts. Population items include age, sex, race, Hispanic or Latino origin, household type, family type, relationship to householder, group quarters population, housing occupancy and housing tenure (whether a housing unit is owner-occupied or renter-occupied). #> 2 This product will include key socio-demographic and economic variables presented in cross-tabulations that present the complex data together. #> 3 This product will include…. #> 4 This product will include key socio-demographic and economic variables presented in cross-tabulations that present the complex data together. #> 5 This product will include key socio-demographic and economic variables presented in cross-tabulations that present the complex data together. #> 6 This product provides the population counts and sex and age statistics for detailed racial and ethnic groups and American Indian and Alaska Native tribes and villages. #> contact #> 1 pio@census.gov #> 2 pio@census.gov #> 3 pio@census.gov #> 4 pio@census.gov #> 5 pio@census.gov #> 6 pio@census.gov # Get information about one particular dataset api_sahie <- listCensusApis(name = \"timeseries/healthins/sahie\") head(api_sahie) #> title #> 1 Small Area Health Insurance Estimates: Small Area Health Insurance Estimates #> name type temporal spatial #> 1 timeseries/healthins/sahie Timeseries 2006/2020 US #> url modified #> 1 http://api.census.gov/data/timeseries/healthins/sahie 2021-04-12 00:00:00.0 #> description #> 1 The U.S. Census Bureau's Small Area Health Insurance Estimates program produces the only source of data for single-year estimates of health insurance coverage status for all counties in the U.S. by selected economic and demographic characteristics. This program is partially funded by the Centers for Disease Control and Prevention's (CDC) Division of Cancer Prevention and Control (DCPC). The CDC have a congressional mandate to provide screening services for breast and cervical cancer to low-income, uninsured, and underserved women through the National Breast and Cervical Cancer Early Detection Program (NBCCEDP). For estimation, SAHIE uses statistical models that combine survey data from the American Community Survey (ACS) with administrative records data and Census 2010 data. #> contact #> 1 Sehsd.sahie@census.gov"},{"path":"https://www.hrecht.com/censusapi/reference/listCensusMetadata.html","id":null,"dir":"Reference","previous_headings":"","what":"Get metadata about a specified API endpoint — listCensusMetadata","title":"Get metadata about a specified API endpoint — listCensusMetadata","text":"Get information Census Bureau API dataset, including available variables, geographies, variable groups, value labels","code":""},{"path":"https://www.hrecht.com/censusapi/reference/listCensusMetadata.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get metadata about a specified API endpoint — listCensusMetadata","text":"","code":"listCensusMetadata( name, vintage = NULL, type = \"variables\", group = NULL, variable_name = NULL, include_values = FALSE )"},{"path":"https://www.hrecht.com/censusapi/reference/listCensusMetadata.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get metadata about a specified API endpoint — listCensusMetadata","text":"name API programmatic name - e.g. acs/acs5. Use listCensusApis() see valid dataset names. vintage Vintage (year) dataset. required timeseries APIs. type Type metadata return. Options : \"variables\" (default) - list variable names descriptions dataset. \"geographies\" - available geographies. \"groups\" - available variable groups. available datasets. \"values\" - encoded value labels given variable. Pair \"variable_name\". available datasets. group optional variable group code, used return metadata specific group variables . Variable groups used APIs. variable_name name specific variable used return value labels variable. Value labels used APIs. include_values Use type = \"variables\". Include value metadata variables dataset value metadata exists. Default \"FALSE\".","code":""},{"path":"https://www.hrecht.com/censusapi/reference/listCensusMetadata.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get metadata about a specified API endpoint — listCensusMetadata","text":"data frame metadata specified API endpoint.","code":""},{"path":[]},{"path":"https://www.hrecht.com/censusapi/reference/listCensusMetadata.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Get metadata about a specified API endpoint — listCensusMetadata","text":"","code":"# type: variables # List the variables available in the Small Area # Health Insurance Estimates. variables <- listCensusMetadata( name = \"timeseries/healthins/sahie\", type = \"variables\") head(variables) #> name #> 1 for #> 2 in #> 3 time #> 4 NIPR_LB90 #> 5 NIPR_PT #> 6 AGECAT #> label #> 1 Census API FIPS 'for' clause #> 2 Census API FIPS 'in' clause #> 3 ISO-8601 Date/Time value #> 4 Number in Demographic Group for Selected Income Range, Upper Bound for 90% Confidence Interval #> 5 Number in Demographic Group for Selected Income Range, Estimate #> 6 Age Category #> concept predicateType group limit predicateOnly #> 1 Census API Geography Specification fips-for N/A 0 TRUE #> 2 Census API Geography Specification fips-in N/A 0 TRUE #> 3 Census API Date/Time Specification datetime N/A 0 TRUE #> 4 int N/A 0 #> 5 int N/A 0 #> 6 string N/A 0 #> required #> 1 #> 2 #> 3 true #> 4 #> 5 #> 6 default displayed # type: variables for a single variable group # List the variables that are included in the B17020 group in the # 5-year American Community Survey. variable_group <- listCensusMetadata( name = \"acs/acs5\", vintage = 2022, type = \"variables\", group = \"B17020\") head(variable_group) #> name #> 1 B17020_017EA #> 2 B17020_016MA #> 3 B17020_016EA #> 4 B17020_015MA #> 5 B17020_015EA #> 6 B17020_014EA #> label #> 1 Annotation of Estimate!!Total:!!Income in the past 12 months at or above poverty level:!!85 years and over #> 2 Annotation of Margin of Error!!Total:!!Income in the past 12 months at or above poverty level:!!75 to 84 years #> 3 Annotation of Estimate!!Total:!!Income in the past 12 months at or above poverty level:!!75 to 84 years #> 4 Annotation of Margin of Error!!Total:!!Income in the past 12 months at or above poverty level:!!60 to 74 years #> 5 Annotation of Estimate!!Total:!!Income in the past 12 months at or above poverty level:!!60 to 74 years #> 6 Annotation of Estimate!!Total:!!Income in the past 12 months at or above poverty level:!!18 to 59 years #> concept predicateType group limit #> 1 Poverty Status in the Past 12 Months by Age string B17020 0 #> 2 Poverty Status in the Past 12 Months by Age string B17020 0 #> 3 Poverty Status in the Past 12 Months by Age string B17020 0 #> 4 Poverty Status in the Past 12 Months by Age string B17020 0 #> 5 Poverty Status in the Past 12 Months by Age string B17020 0 #> 6 Poverty Status in the Past 12 Months by Age string B17020 0 #> predicateOnly universe #> 1 TRUE Population for whom poverty status is determined #> 2 TRUE Population for whom poverty status is determined #> 3 TRUE Population for whom poverty status is determined #> 4 TRUE Population for whom poverty status is determined #> 5 TRUE Population for whom poverty status is determined #> 6 TRUE Population for whom poverty status is determined # type: variables, with value labels # Create a data dictionary with all variable names and encoded values # for a microdata API. variable_values <- listCensusMetadata( name = \"cps/voting/nov\", vintage = 2020, type = \"variables\", include_values = TRUE) head(variable_values) #> name label #> 1 for Census API FIPS 'for' clause #> 2 in Census API FIPS 'in' clause #> 3 ucgid Uniform Census Geography Identifier clause #> 4 PEEDUCA Demographics-highest level of school completed #> 5 PEEDUCA Demographics-highest level of school completed #> 6 PEEDUCA Demographics-highest level of school completed #> concept predicateType group limit predicateOnly #> 1 Census API Geography Specification fips-for N/A 0 TRUE #> 2 Census API Geography Specification fips-in N/A 0 TRUE #> 3 Census API Geography Specification ucgid N/A 0 TRUE #> 4 int N/A 0 #> 5 int N/A 0 #> 6 int N/A 0 #> suggested_weight is_weight values_code values_label #> 1 #> 2 #> 3 #> 4 PWSSWGT 46 DOCTORATE DEGREE(EX:PhD,EdD) #> 5 PWSSWGT 33 5th Or 6th Grade #> 6 PWSSWGT 44 MASTER'S DEGREE(EX:MA,MS,MEng,MEd,MSW) # type: geographies # List the geographies available in the 5-year American Community Survey. geographies <- listCensusMetadata( name = \"acs/acs5\", vintage = 2022, type = \"geographies\") head(geographies) #> name geoLevelDisplay referenceDate requires wildcard #> 1 us 010 2022-01-01 NULL NULL #> 2 region 020 2022-01-01 NULL NULL #> 3 division 030 2022-01-01 NULL NULL #> 4 state 040 2022-01-01 NULL NULL #> 5 county 050 2022-01-01 state state #> 6 county subdivision 060 2022-01-01 state, county county #> optionalWithWCFor #> 1 #> 2 #> 3 #> 4 #> 5 state #> 6 county # type: groups # List the variable groups available in the 5-year American # Community Survey. groups <- listCensusMetadata( name = \"acs/acs5\", vintage = 2022, type = \"groups\") head(groups) #> name #> 1 B17015 #> 2 B18104 #> 3 B17016 #> 4 B18105 #> 5 B17017 #> 6 B18106 #> description #> 1 Poverty Status in the Past 12 Months of Families by Family Type by Social Security Income by Supplemental Security Income (SSI) and Cash Public Assistance Income #> 2 Sex by Age by Cognitive Difficulty #> 3 Poverty Status in the Past 12 Months of Families by Family Type by Work Experience of Householder and Spouse #> 4 Sex by Age by Ambulatory Difficulty #> 5 Poverty Status in the Past 12 Months by Household Type by Age of Householder #> 6 Sex by Age by Self-Care Difficulty #> variables #> 1 http://api.census.gov/data/2022/acs/acs5/groups/B17015.json #> 2 http://api.census.gov/data/2022/acs/acs5/groups/B18104.json #> 3 http://api.census.gov/data/2022/acs/acs5/groups/B17016.json #> 4 http://api.census.gov/data/2022/acs/acs5/groups/B18105.json #> 5 http://api.census.gov/data/2022/acs/acs5/groups/B17017.json #> 6 http://api.census.gov/data/2022/acs/acs5/groups/B18106.json #> universe #> 1 Families #> 2 Civilian noninstitutionalized population 5 years and over #> 3 Families #> 4 Civilian noninstitutionalized population 5 years and over #> 5 Households #> 6 Civilian noninstitutionalized population 5 years and over # type: values for a single variable # List the value labels of the NAICS2017 variable in the County # Business Patterns dataset. naics_values <- listCensusMetadata( name = \"cbp\", vintage = 2021, type = \"values\", variable = \"NAICS2017\") head(naics_values) #> code label #> 1 00 Total for all sectors #> 2 000000 Industry total #> 3 11 Agriculture, forestry, fishing and hunting #> 4 111 Crop production #> 5 1111 Oilseed and grain farming #> 6 11111 Soybean farming"},{"path":"https://www.hrecht.com/censusapi/reference/makeVarlist.html","id":null,"dir":"Reference","previous_headings":"","what":"Use variable metadata to find variables containing a given string — makeVarlist","title":"Use variable metadata to find variables containing a given string — makeVarlist","text":"Return list variable names data frame variable metadata containing given string. can used create list variables later pass getCensus, data frame documenting variables used given project.","code":""},{"path":"https://www.hrecht.com/censusapi/reference/makeVarlist.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Use variable metadata to find variables containing a given string — makeVarlist","text":"","code":"makeVarlist(name, vintage = NULL, find, varsearch = \"all\", output = \"list\")"},{"path":"https://www.hrecht.com/censusapi/reference/makeVarlist.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Use variable metadata to find variables containing a given string — makeVarlist","text":"name API programmatic name - e.g. acs/acs5. Use listCensusApis() see valid dataset names. vintage Vintage (year) dataset. required timeseries APIs. find string find variable metadata. varsearch Optional argument specifying fields search. Default \"\". Options \"\", \"name\", \"label\", \"concept\". output Optional argument, specifying output \"list\" \"dataframe\". Default \"list\".","code":""},{"path":"https://www.hrecht.com/censusapi/reference/makeVarlist.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Use variable metadata to find variables containing a given string — makeVarlist","text":"data frame containing variable metadata","code":""},{"path":[]},{"path":"https://www.hrecht.com/censusapi/reference/makeVarlist.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Use variable metadata to find variables containing a given string — makeVarlist","text":"","code":"# Return a list, and then use getCensus function to retrieve those variables myvars <- makeVarlist(name = \"timeseries/poverty/saipe\", find = \"Ages 0-4\", varsearch = \"label\") myvars #> [1] \"SAEPOVRT0_4_UB90\" \"SAEPOVRT0_4_MOE\" \"SAEPOVRT0_4_LB90\" \"SAEPOVRT0_4_PT\" #> [5] \"SAEPOV0_4_PT\" \"SAEPOVU_0_4\" \"SAEPOV0_4_MOE\" \"SAEPOV0_4_UB90\" #> [9] \"SAEPOV0_4_LB90\" saipe_dt <- getCensus(name = \"timeseries/poverty/saipe\", time = 2016, vars = myvars, region = \"state:*\") head(saipe_dt) #> time state SAEPOVRT0_4_UB90 SAEPOVRT0_4_MOE SAEPOVRT0_4_LB90 SAEPOVRT0_4_PT #> 1 2016 01 28.9 1.5 25.9 27.4 #> 2 2016 02 17.0 1.9 13.2 15.1 #> 3 2016 04 26.1 1.2 23.7 24.9 #> 4 2016 05 29.1 1.8 25.5 27.3 #> 5 2016 06 21.2 0.5 20.2 20.7 #> 6 2016 08 15.1 1.2 12.7 13.9 #> SAEPOV0_4_PT SAEPOVU_0_4 SAEPOV0_4_MOE SAEPOV0_4_UB90 SAEPOV0_4_LB90 #> 1 78675 287177 4418 83093 74257 #> 2 7919 52408 1021 8940 6898 #> 3 106817 428317 5131 111948 101686 #> 4 50341 184115 3246 53587 47095 #> 5 502432 2430975 13017 515449 489415 #> 6 46111 330815 3894 50005 42217"},{"path":[]},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"breaking-changes-0-9-0","dir":"Changelog","previous_headings":"","what":"Breaking changes","title":"censusapi 0.9.0 (development verison)","text":"Increases required version R >=3.0 >=3.5 (released 2018) based httr dependency.","code":""},{"path":[]},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"api-keys-0-9-0","dir":"Changelog","previous_headings":"New features","what":"API keys","title":"censusapi 0.9.0 (development verison)","text":"getCensus() longer requires key, use Census Bureau API key. Users still encouraged register use API key Census Bureau may rate limit IP addresses, required. (#87) New get_api_key() helper function retrieves value user’s stored Census Bureau API key saved environment variable provides warning message none found.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"metadata-0-9-0","dir":"Changelog","previous_headings":"New features","what":"Metadata","title":"censusapi 0.9.0 (development verison)","text":"listCensusApis() now optional name vintage parameters get metadata subset datasets single dataset. (#103)","code":"# Get metadata for all 2020 Decennial Census datasets apis_decennial_2020 <- listCensusApis(name = \"dec\", vintage = 2020) # Get metadata for all timeseries datasets apis_timeseries <- listCensusApis(name = \"timeseries\")"},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"minor-improvements-0-9-0","dir":"Changelog","previous_headings":"","what":"Minor improvements","title":"censusapi 0.9.0 (development verison)","text":"getCensus() automatically converts data columns Household Pulse Survey (name = \"timeseries/hps\") numeric. New has_api_key() helper function detects stored Census Bureau API key Renviron, intended mainly internal use.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"documentation-0-9-0","dir":"Changelog","previous_headings":"","what":"Documentation","title":"censusapi 0.9.0 (development verison)","text":"Function documentation improved better formatted. Examples updated use newly released datasets. new online frequently asked questions article improves documentation. new vignette included package build directs users website read web-articles.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-080","dir":"Changelog","previous_headings":"","what":"censusapi 0.8.0","title":"censusapi 0.8.0","text":"CRAN release: 2022-08-09 listCensusApis() new columns resulting data frame available API endpoints: API contact email address type: either Aggregate, Timeseries, Microdata. listCensusMetadata() new functionality use value metadata. particularly useful economic datasets microdata APIs. Use type = \"variables\" include_values = TRUE create dictionary value labels given dataset. get value labels single variable given dataset, use type = \"values\" variable = \"VARIABLE INTEREST\". Note: metadata, incredibly useful, exists datasets. datasets ’ll still need reference external files Census Bureau adds functionality. example, get value labels NAICS2017 County Business Patterns dataset: make full dictionary Current Population Survey Voting Patterns microdata API: getCensus() new option convert_variables re discussion (#68) (#80). default TRUE — previous versions, converts columns numbers R’s numeric data type. Setting convert variables = FALSE leaves columns original character data type returned Census Bureau. getCensus() improved data binding responses requests 50 variables manually specified. Occasionally large requests returned Census Bureau order, leading mismatched rows. fixes (#82). listCensusMetadata() now properly handles metadata attribute names new Microdata APIs contain invalid JSON. fixes (#84). Documentation examples updated. new vignette: Accessing microdata.","code":"cbp_naics_values <- listCensusMetadata( name = \"cbp\", vintage = 2020, type = \"values\", variable = \"NAICS2017\") cbp_dict <- listCensusMetadata( name = \"cbp\", vintage = 2020, type = \"variables\", include_values = TRUE)"},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-073","dir":"Changelog","previous_headings":"","what":"censusapi 0.7.3","title":"censusapi 0.7.3","text":"Properly types certain variables international trade timeseries APIs.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-072","dir":"Changelog","previous_headings":"","what":"censusapi 0.7.2","title":"censusapi 0.7.2","text":"Adds named parameter YEAR getCensus() per changes timeseries endpoints previously used TIME parameter. Updates examples using SAHIE SAIPE APIs per Census Bureau changes endpoints.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-071","dir":"Changelog","previous_headings":"","what":"censusapi 0.7.1","title":"censusapi 0.7.1","text":"CRAN release: 2020-10-14 Removes listCensusMetadata() masterlist examples used Business Dynamic Statistics endpoints, recently deprecated.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-070","dir":"Changelog","previous_headings":"","what":"censusapi 0.7.0","title":"censusapi 0.7.0","text":"CRAN release: 2020-09-07 Adds show_call option getCensus(), shows underlying API call (otherwise shown errors) link package documentation used. Converts improperly formatted string “N/” “NULL” values underlying Census data true NA values. Keeps 2017 NAICS variables characters, instead erroneously converting numeric. Parses endpoint numeric variables -character variable names numeric several popular endpoints: SAHIE, SAIPE, ZBP, CBP, PEP Decennial Response Rates. Removes examples deprecated 1990 2000 Decennial endpoints.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-061","dir":"Changelog","previous_headings":"","what":"censusapi 0.6.1","title":"censusapi 0.6.1","text":"Updates web link FIPS codes reference Census website reorganization. Adds examples Decennial Census response rates, updates several examples retrieve newer data. Removes example masterlist package due size, online .","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-060","dir":"Changelog","previous_headings":"","what":"censusapi 0.6.0","title":"censusapi 0.6.0","text":"CRAN release: 2019-04-13 Allows use miscellaneous paramaters getCensus(). allows users specify valid API argument name pass value, giving full access underlying Census Bureau APIs. Adds group parameter listCensusMetadata(). allows users get variable metadata specified variable group. Improves internal logic listCensusMetadata(). Add documentation examples using miscellaneous paramaters. Returns underlying API call error messages, particularly useful users needing Census Bureau. Specifies tract block group example due underlying API changes. Adds Contributor Code Conduct.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-050","dir":"Changelog","previous_headings":"","what":"censusapi 0.5.0","title":"censusapi 0.5.0","text":"Makes region optional argument getCensus, rather required. Pads fips codes stored fips dataset zeroes.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-041","dir":"Changelog","previous_headings":"","what":"censusapi 0.4.1","title":"censusapi 0.4.1","text":"CRAN release: 2018-08-19 Adds groups type option listCensusMetadata. Fixes bug listCensusMetadata variables call caused underlying Census API change, renamed validValues values endpoints. Converts variable metadata columns factors characters. Applies numeric conversion exclusions API endpoints. Improves language surrounding error messages Census Bureau returns. Updates 2010 Decennial Census examples use new 2010 dec/sf1 endpoint, replace 2010 sf1 endpoint August 30, 2018.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-040","dir":"Changelog","previous_headings":"","what":"censusapi 0.4.0","title":"censusapi 0.4.0","text":"Adds support NAICS code arguments used Business Patterns APIs, Economic Census APIs, Annual Survey Manufactures APIs.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-030","dir":"Changelog","previous_headings":"","what":"censusapi 0.3.0","title":"censusapi 0.3.0","text":"CRAN release: 2018-05-02 convert ACS annotation flag variables numeric columns. Puts lowercase variable name columns first (geographies), rather non-numeric columns. Changes punctuation returned column names underscores, removing repeated underscores trailing punctuation. Uses consistent spacing examples. Updates examples using ACS data latest year using new acs/acs5 endpoint adds variable group examples.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-021","dir":"Changelog","previous_headings":"","what":"censusapi 0.2.1","title":"censusapi 0.2.1","text":"CRAN release: 2017-08-01 Fixes bug listCensusMetadata variables call caused underlying Census API changes.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-020","dir":"Changelog","previous_headings":"","what":"censusapi 0.2.0","title":"censusapi 0.2.0","text":"CRAN release: 2017-06-06 Updated examples, documentation, vignette.","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-012","dir":"Changelog","previous_headings":"","what":"censusapi 0.1.2","title":"censusapi 0.1.2","text":"Fixes bug caused single-row responses throw error","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-011","dir":"Changelog","previous_headings":"","what":"censusapi 0.1.1","title":"censusapi 0.1.1","text":"Uses https rather http requests. Census Bureau announced APIs https-beginning August 28, 2017. Note: change generally increased run time retrieving variable metadata listCensusMetadata. APIs, function run one second. lag may noticeable American Community Survey APIs, 40,000 variables. Improvements planned future releases. listCensusMetadata allows full word single letter argument type parameter","code":""},{"path":"https://www.hrecht.com/censusapi/news/index.html","id":"censusapi-010","dir":"Changelog","previous_headings":"","what":"censusapi 0.1.0","title":"censusapi 0.1.0","text":"Scrapes http://api.census.gov/data.json rather .html listCensusApis, starts removing XML dependency. .json data also includes several fields present .html file, useful added returned data frame. Changes dataset used listCensusMetadata examples, mainly build/checks speed. Set getCensus(key) argument’s default value CENSUS_KEY .Renviron. Explicitly encourages Census key added .Renviron. (Users can always override given input.) Parses HTML response code. particularly important response Census APIs provided invalid keys. Removes fips code 72 (Puerto Rico) included fips dataset Puerto Rico included Census API datasets. Changes census key references examples Sys.getenv(“CENSUS_KEY”).","code":""}] diff --git a/man/getCensus.Rd b/man/getCensus.Rd index 8a82eb3..3264ed5 100644 --- a/man/getCensus.Rd +++ b/man/getCensus.Rd @@ -39,7 +39,7 @@ dataset names. Required.} timeseries APIs.} \item{key}{A Census API key, obtained at -https://api.census.gov/data/key_signup.html. If you have a \code{CENSUS_KEY} or +\url{https://api.census.gov/data/key_signup.html}. If you have a \code{CENSUS_KEY} or \code{CENSUS_API_KEY} stored in your .Renviron file, getCensus() will automatically use that key. Using a key is recommended but not required.} diff --git a/man/has_api_key.Rd b/man/has_api_key.Rd index 135d33c..f068fb3 100644 --- a/man/has_api_key.Rd +++ b/man/has_api_key.Rd @@ -2,12 +2,15 @@ % Please edit documentation in R/api-key.R \name{has_api_key} \alias{has_api_key} -\title{Is there a saved API token?} +\title{Is there a saved Census API key in the .Renivron file?} \usage{ has_api_key() } +\value{ +TRUE or FALSE. +} \description{ -Is there a saved API token? +Is there a saved Census API key in the .Renivron file? } \examples{ has_api_key()

202102Alaska20.80All Races01Alabama40.43Hispanic or Latino (any race) 5 1
202104Arizona18.90All Races01Alabama20.84American Indian and Alaska Native alone, not Hispanic +or Latino 5 1
202104Arizona12.01White alone, not Hispanic or Latino01Alabama14.85Asian alone, not Hispanic or Latino 5 1
25 Annual Survey of School System FinanceSS0707Current spending - Support services - Pupil -transportation711407SS0701Current spending - Support services - Total6185866 06 001
25 Annual Survey of School System FinanceSS0708Current spending - Support services - Other and -nonspecified support services418997SS0702Current spending - Support services - Pupil support +services1551012 06 001
25 Annual Survey of School System FinanceSS0706Current spending - Support services - Operation and -maintenance of plant1525154SS0703Current spending - Support services - Instructional +staff support services902090 06 001