From 6ba5979412a3e378009fd0b5bdb3e97a52caae0e Mon Sep 17 00:00:00 2001 From: Hannah Recht Date: Fri, 5 Apr 2024 12:54:16 -0400 Subject: [PATCH] overhaul numeric column typing logic --- NEWS.md | 7 +- R/getcensus_functions.R | 162 ++- docs/articles/accessing-microdata.html | 14 +- docs/articles/example-list.html | 1456 +++++++++++++----------- docs/articles/getting-started.html | 88 +- docs/news/index.html | 12 +- docs/pkgdown.yml | 2 +- docs/search.json | 2 +- vignettes/articles/example-list.Rmd | 29 + 9 files changed, 1008 insertions(+), 764 deletions(-) diff --git a/NEWS.md b/NEWS.md index 3ee2c73..4cb218a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,7 +6,10 @@ ### 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. +* New `has_api_key()` helper function detects if there is a stored Census Bureau API key in the Renviron, intended mainly for internal use. +### Variable typing +* `getCensus()` uses improved logic to automatically convert columns that contain all numbers to numeric, unless the column name is in a specific list of geography names or other string type columns. Use `convert_variable = FALSE` to leave all columns as characters. ### Metadata * `listCensusApis()` now has optional `name` and `vintage` parameters to get metadata for a subset of datasets or a single dataset. (#103) @@ -19,10 +22,6 @@ apis_decennial_2020 <- listCensusApis(name = "dec", vintage = 2020) 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. * Examples are updated to use newly released datasets. diff --git a/R/getcensus_functions.R b/R/getcensus_functions.R index 66dd765..d42e420 100644 --- a/R/getcensus_functions.R +++ b/R/getcensus_functions.R @@ -52,70 +52,126 @@ getFunction <- function(apiurl, name, key, get, region, regionin, time, show_cal # Make all columns character df[] <- lapply(df, as.character) - # Make columns numeric based on column names - unfortunately best strategy without additional API calls given structure of data across endpoints - if (convert_variables == TRUE) { - string_col_parts <- "_TTL|_NAME|NAICS2012|NAICS2017|NAICS2012_TTL|NAICS2017_TTL|fage4|FAGE4|LABEL|_DESC|CAT" - - # For ACS data, do not make columns numeric if they are ACS annotation variables - ending in MA or EA or SS - if (grepl("acs/acs", name, ignore.case = T)) { - # Do not make known string/label variables numeric - numeric_cols <- grep("[0-9]", names(df), value=TRUE) - string_cols <- grep(paste0("MA|EA|SS|", string_col_parts), numeric_cols, value = TRUE, ignore.case = T) - # Small Area Health Insurance Estimates - } else if (grepl("healthins/sahie", name, ignore.case = T)) { - numeric_cols <- grep("[0-9]|_PT|NIPR|PCTIC|PCTUI|NIC|NUI", names(df), value=TRUE, ignore.case = T) - string_cols <- grep(string_col_parts, numeric_cols, value = TRUE, ignore.case = T) + # Make columns numeric unless they're in specific string/geography column names lists + # Microdata weighting variables + # } else if (grepl("cps/", name, ignore.case = T) | + # name %in% c("acs/acs5/pums", "acs/acs5/pumspr", "acs/acs1/pums", "acs/acs1/pumspr")) { + # numeric_cols <- grep("[0-9]|PWSSWGT|HWHHWGT|PWFMWGT|PWLGWGT|PWCMPWGT|PWORWGT|PWVETWGT|WGTP|PWGTP", names(df), value=TRUE, ignore.case = T) + # string_cols <- grep(common_string_cols, numeric_cols, value = TRUE, ignore.case = T) + # + # } - # Small Area Income and Poverty Estimates - } else if (grepl("poverty/saipe", name, ignore.case = T)) { - numeric_cols <- grep("[0-9]|SAEMHI|SAEPOV", names(df), value=TRUE, ignore.case = T) - string_cols <- grep(string_col_parts, numeric_cols, value = TRUE, ignore.case = T) - - # Population and Housing Estimates - } else if (grepl("pep/", name, ignore.case = T)) { - numeric_cols <- grep("[0-9]|POP|DENSITY|HUEST", names(df), value=TRUE, ignore.case = T) - string_cols <- grep(string_col_parts, numeric_cols, value = TRUE, ignore.case = T) + if (convert_variables == TRUE) { + # If these are part of the variable name, keep as string + string_col_parts_list <- c("_TTL", "_NAME", "NAICS", "FAGE4", "LABEL", + "_DESC", "CAT", "UNIT_QY", "_FLAG", + "DISTRICT", "EMPSZES", "POPGROUP") - # County Business Patterns - } else if (name == "cbp" | name == "zbp") { - # Exact matches for CBP variables - numeric_cols <- grep("[0-9]|\\|\\|PAYANN", names(df), value=TRUE, ignore.case = T) - string_cols <- grep(string_col_parts, numeric_cols, value = TRUE, ignore.case = T) + # Geography variables - exact matches only + geos_list <- c("GEO_ID", "GEOID", "GEOID1", "GEOID2", "GEOCOMP", + "SUMLEVEL", "GEOTYPE", "GEOMAME", "GEOVARIANT", + # Top-level geographies + "NATION", "US", "DIVISION", "REGION", "LSAD_NAME", + # Summary levels - but not ACS Flows SUMLEV1 and SUMLEV2 ints + "SUMLEVEL", "SUMMARY_LVL", + # States + "STATE", "ST", "STNAME", + # Counties + "COUNTY", "CTY_CODE", "CTY_NAME", "CTYNAME", "EEOCOUNTY", + "COUSUB", "COUNTY1", "COUNTY2", + # Tracts + "TRACT", + # Places and cities + "PLACE", "PLACEREM", "CONCITY", "CONSCITY", "PRINCITY", "SUBMCD", + # PUMAs + "PUMA", "PUMA5", "MIGPUMA", "POWPUMA", + # Blocks + "BH", "BLKGRP", "BLOCK", "BLOCK_GROUP", "GIDBG", + # AIAN geographies + "AIANHH", "AIARO", "AIHHTL", "AIRES", "ANRC", "TTRACT", + "TBLKGRP", "TRIBALBG", "TRIBALCT", "TRIBALSUB", "TRISUBREM", + # Metro areas + "CSA", "MSA", "CBSA", "METDIV", "MSACMSA", + "METROPOLITAN_STATISTICAL_AREA_MICROPOLITAN_STATISTICAL_AREA", + # Congressional districts + "CD", "CD106", "CD107", "CD108", "CD109", "CD110", "CD111", + "CD112", "CD113", "CD114", "CD115", "CD116", "CDCURR", + # Future proof congress for a while + "CD117", "CD118", "CD119", + # State legislative districts + "SLDL", "SLDU", + # NECTAs and related + "CNECTA", "NECTA", "NECTADIV", "NECMA", + # School districts + "SDELM", "SDSEC", "SDUNI", + # Sub-Minor Civil Division + "SUBMCD", + # ZCTAs + "ZIPCODE", "ZCTA", "ZCTA5", "ZCTA3", + # Urban area, Urban/rural + "UA", "UR", + # Voting district + "VTD", + # Imports and exports geographies + "USITC", "USITCHISTORY", "USITCREG", "CUSTDISTRICT", "DIST_NAME", + "PORT", "WORLD", + # Various Economic APIs geographies + "CFSAREA", "COMMREG", "ECPLACE", + # 2020 Decennial + "ESTATE", + # Random rarely-used geographies + "ESTPLACE", "EUCOUSUB", "EUPB", "GENC", + # CPS microdata + "GESTFIPS", "GTCO", "HG_FIPS", + # SIPP microdata + "TFIPSST") - # Decennial Response Rates - } else if (name == "dec/responserate") { - numeric_cols <- grep("[0-9]|CINT|MIN|MED|AVG|MAX|DRR|CRR", names(df), value=TRUE, ignore.case = T) - string_cols <- grep(string_col_parts, numeric_cols, value = TRUE, ignore.case = T) + collapse_col_parts <- function(parts) { + collapsed <- paste0(parts, collapse = "|") + return(collapsed) + } + common_string_cols <- collapse_col_parts(string_col_parts_list) - # International trade - } else if (grepl("timeseries/intltrade/", name, ignore.case = T)) { - numeric_cols <- grep("[0-9]", names(df), value=TRUE, ignore.case = T) - string_col_parts <- paste0(string_col_parts, "|UNIT_QY|_FLAG") - string_cols <- grep(string_col_parts, numeric_cols, value = TRUE, ignore.case = T) + # Columns that match geos_list exactly + geo_cols <- names(df)[toupper(names(df)) %in% geos_list] - # Household Pulse Survey - } else if (name == "timeseries/hps") { - numeric_cols <- grep("_RATE|_TOTAL|_UNIV|_MOE|WEEK", names(df), value=TRUE, ignore.case = T) - string_cols <- grep(string_col_parts, numeric_cols, value = TRUE, ignore.case = T) + # Microdata APIs - don't convert string identifier variables that appear + # in >5 endpoints as strings only or nearly always as strings + if (grepl("cps/|pums|sipp", name, ignore.case = T)) { - # Microdata weighting variables - } else if (grepl("cps/", name, ignore.case = T) | - name %in% c("acs/acs5/pums", "acs/acs5/pumspr", "acs/acs1/pums", "acs/acs1/pumspr")) { - numeric_cols <- grep("[0-9]|PWSSWGT|HWHHWGT|PWFMWGT|PWLGWGT|PWCMPWGT -|PWORWGT|PWVETWGT|WGTP|PWGTP", names(df), value=TRUE, ignore.case = T) - string_cols <- grep(string_col_parts, numeric_cols, value = TRUE, ignore.case = T) + common_string_cols <- collapse_col_parts( + c( #SIPP PUMS + "SSUID", + # CPS PUMS + "HRHHID", "HRSAMPLE", "HRSERSUF", "GECMSASZ", "H_ID", "H_ID_PL", + "H_IDNUM", "OCCURNUM", "QSTNUM", + # ACS PUMS + "RT", "SERIALNO", "CONCAT_ID", "RECORD_TYPE", "SOCP", + "OCCP10", "OCCP02", "OCCP12", + common_string_cols)) + } - } else { - # Do not make known string/label variables numeric - numeric_cols <- grep("[0-9]", names(df), value=TRUE) - string_cols <- grep(string_col_parts, numeric_cols, value = TRUE, ignore.case = T) + # For ACS data, also keep as strings ACS annotation variables + # ending in MA or EA or SS + if (grepl("acs/acs", name, ignore.case = T) & !(grepl("pums", name, ignore.case = T))) { + common_string_cols <- collapse_col_parts(c("MA", "EA", "SS", common_string_cols)) } - # Convert string "NULL" or "N/A" values to true NA - df[(df == "NULL" | df == "N/A" | df == "NA")] <- NA + # Columns that contain string parts + string_part_cols <- grep(common_string_cols, names(df), value = TRUE, ignore.case = T) + string_cols <- c(geo_cols, string_part_cols) - for(col in setdiff(numeric_cols, string_cols)) df[,col] <- as.numeric(df[,col]) + # For columns that aren't explicitly defined here as strings, convert them to numeric + # If they are actually all numbers + for(col in setdiff(names(df), string_cols)) { + df[,col] <- utils::type.convert(df[,col], + as.is = TRUE, + # Some returned data contains messy NAs, account for them + na.strings = c(NA, "NULL", "N/A", "NA")) + #} + + } } row.names(df) <- NULL diff --git a/docs/articles/accessing-microdata.html b/docs/articles/accessing-microdata.html index a3e699f..b8ea4ed 100644 --- a/docs/articles/accessing-microdata.html +++ b/docs/articles/accessing-microdata.html @@ -251,7 +251,7 @@

Getting microdata with censusapi state PES5 -PESEX +PESEX PWSSWGT PES1 @@ -259,42 +259,42 @@

Getting microdata with censusapi 36 1 -1 +1 4571.216 1 36 1 -2 +2 4806.369 1 36 1 -2 +2 3440.301 1 36 -3 -1 +1 5204.566 1 36 -3 -2 +2 4993.819 1 36 1 -2 +2 4602.958 1 diff --git a/docs/articles/example-list.html b/docs/articles/example-list.html index 5dce1c7..0a5673d 100644 --- a/docs/articles/example-list.html +++ b/docs/articles/example-list.html @@ -425,9 +425,9 @@

ACS Migration Flows state county -MOVEDIN -MOVEDOUT -GEOID2 +MOVEDIN +MOVEDOUT +GEOID2 FULL1_NAME FULL2_NAME @@ -435,135 +435,135 @@

ACS Migration Flows 06 037 -2585 -NA +2585 NA +NA Los Angeles County, California Africa 06 037 -37932 -NA +37932 NA +NA Los Angeles County, California Asia 06 037 -13073 -NA +13073 NA +NA Los Angeles County, California Central America 06 037 -962 -NA +962 NA +NA Los Angeles County, California Caribbean 06 037 -9953 -NA +9953 NA +NA Los Angeles County, California Europe 06 037 -312 -NA +312 NA +NA Los Angeles County, California U.S. Island Areas 06 037 -1774 -NA +1774 NA +NA Los Angeles County, California Northern America 06 037 -2001 -NA +2001 NA +NA Los Angeles County, California Oceania and At Sea 06 037 -4341 -NA +4341 NA +NA Los Angeles County, California South America 06 037 -0 -7 -1003 +0 +7 +01003 Los Angeles County, California Baldwin County, Alabama 06 037 -9 -0 -1009 +9 +0 +01009 Los Angeles County, California Blount County, Alabama 06 037 -20 -40 -1015 +20 +40 +01015 Los Angeles County, California Calhoun County, Alabama 06 037 -0 -9 -1031 +0 +9 +01031 Los Angeles County, California Coffee County, Alabama 06 037 -0 -60 -1045 +0 +60 +01045 Los Angeles County, California Dale County, Alabama 06 037 -0 -16 -1051 +0 +16 +01051 Los Angeles County, California Elmore County, Alabama @@ -589,45 +589,45 @@

American Community Survey - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -663,9 +663,9 @@

Annual Survey of EntrepreneursGEO_TTL

- + - + @@ -673,54 +673,54 @@

Annual Survey of EntrepreneursUnited States

- + - + - + - + - + - + - + - + - + - + - + - +
stateESTLANESTLAN LANLABEL
3627052256252705225625 Spanish
36NA627NA627 Ladino
36133535620133535620 French
3656456225645622 Patois
36NA624NA624 Cajun
364498062944980629 Portuguese
NAICS2012 NAICS2012_TTLEMPSZFIEMPSZFI EMPSZFI_TTLFIRMPDEMPFIRMPDEMP
00 Total for all sectors0011 All firms54377825437782
1 United States 00 Total for all sectors611611 Firms with no employees547115547115
1 United States 00 Total for all sectors612612 Firms with 1 to 4 employees27687562768756
1 United States 00 Total for all sectors620620 Firms with 5 to 9 employees950224950224
1 United States 00 Total for all sectors630630 Firms with 10 to 19 employees585516585516
1 United States 00 Total for all sectors641641 Firms with 20 to 49 employees376051376051
@@ -768,193 +768,193 @@

Annual Survey of Entrepreneursus GEO_TTL NAICS2012_TTL -ASECB +ASECB ASECB_TTL SPOUSES SPOUSES_TTL -YEAR -FIRMPDEMP -FIRMPDEMP_PCT -RCPPDEMP +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 +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 1 United States Total for all sectors -0000 +0 All firms A1 All firms -2014 -5437782 -0.0 -33036935112 +2014 +5437782 +0.0 +33036935112 NA -0.0 -115129295 -0.0 -5640982990 -0.0 -0.0 -0.0 -0.5 -0.0 -0.3 -0.0 -0.3 -0.0 +0.0 +115129295 +0.0 +5640982990 +0.0 +0.0 +0.0 +0.5 +0.0 +0.3 +0.0 +0.3 +0.0 1 United States Total for all sectors -0000 +0 All firms MA Jointly owned but primarily operated by male spouse -2014 -336310 -30.7 -603733952 +2014 +336310 +30.7 +603733952 NA -18.8 -3015332 -21.0 -109460428 -20.2 -0.8 -0.3 -3.2 -1.8 -1.8 -3.5 -3.0 -3.5 +18.8 +3015332 +21.0 +109460428 +20.2 +0.8 +0.3 +3.2 +1.8 +1.8 +3.5 +3.0 +3.5 1 United States Total for all sectors -0000 +0 All firms LZ Jointly owned and equally operated by spouses -2014 -335149 -30.6 -493143589 +2014 +335149 +30.6 +493143589 NA -15.4 -3303608 -23.0 -104343482 -19.2 -0.6 -0.3 -3.7 -5.5 -1.7 -6.2 -1.8 -5.5 +15.4 +3303608 +23.0 +104343482 +19.2 +0.6 +0.3 +3.7 +5.5 +1.7 +6.2 +1.8 +5.5 1 United States Total for all sectors -0000 +0 All firms MB Jointly owned but primarily operated by female spouse -2014 -96475 -8.8 -140228793 +2014 +96475 +8.8 +140228793 NA -4.4 -850573 -5.9 -25984506 -4.8 -1.9 -0.2 -12.6 -1.1 -3.6 -0.6 -4.7 -0.3 +4.4 +850573 +5.9 +25984506 +4.8 +1.9 +0.2 +12.6 +1.1 +3.6 +0.6 +4.7 +0.3 1 United States Total for all sectors -0000 +0 All firms MC Not jointly owned by spouses -2014 -328625 -30.0 -1966858366 +2014 +328625 +30.0 +1966858366 NA -61.4 -7222018 -50.2 -302838280 -55.8 -0.6 -0.5 -2.5 -8.1 -1.6 -10.3 -1.9 -9.0 +61.4 +7222018 +50.2 +302838280 +55.8 +0.6 +0.5 +2.5 +8.1 +1.6 +10.3 +1.9 +9.0 1 United States Total for all sectors -0000 +0 All firms MD Total reporting -2014 -1096559 -100.0 -3203964700 +2014 +1096559 +100.0 +3203964700 NA -100.0 -14391531 -100.0 -542626696 -100.0 -0.2 -0.0 -1.8 -0.0 -0.9 -0.0 -1.3 -0.0 +100.0 +14391531 +100.0 +542626696 +100.0 +0.2 +0.0 +1.8 +0.0 +0.9 +0.0 +1.3 +0.0 @@ -991,11 +991,11 @@

Annual Survey of EntrepreneursASECBO_TTL ACQBUS ACQBUS_TTL -YEAR -OWNPDEMP -OWNPDEMP_PCT -OWNPDEMP_S -OWNPDEMP_PCT_S +YEAR +OWNPDEMP +OWNPDEMP_PCT +OWNPDEMP_S +OWNPDEMP_PCT_S @@ -1006,11 +1006,11 @@

Annual Survey of EntrepreneursAll owners of respondent firms CA Founded or started -2014 -4063687 -70.4 -0.2 -0.3 +2014 +4063687 +70.4 +0.2 +0.3 1 @@ -1020,11 +1020,11 @@

Annual Survey of EntrepreneursAll owners of respondent firms CB Purchased -2014 -1211902 -21.0 -0.5 -0.2 +2014 +1211902 +21.0 +0.5 +0.2 1 @@ -1034,11 +1034,11 @@

Annual Survey of EntrepreneursAll owners of respondent firms CC Inherited -2014 -227408 -3.9 -1.7 -0.1 +2014 +227408 +3.9 +1.7 +0.1 1 @@ -1048,11 +1048,11 @@

Annual Survey of EntrepreneursAll owners of respondent firms CD Transfer of ownership or gift -2014 -405356 -7.0 -0.6 -0.1 +2014 +405356 +7.0 +0.6 +0.1 1 @@ -1062,11 +1062,11 @@

Annual Survey of EntrepreneursAll owners of respondent firms CE Total reporting -2014 -5768389 -100.0 -0.2 -0.0 +2014 +5768389 +100.0 +0.2 +0.0 1 @@ -1076,11 +1076,11 @@

Annual Survey of EntrepreneursAll owners of respondent firms CF Item not reported -2014 -14476 -0.0 -7.3 -0.0 +2014 +14476 +0.0 +7.3 +0.0 @@ -1102,60 +1102,60 @@

Annual Survey of Manufactures - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1180,25 +1180,185 @@

Annual Survey of Manufactures

- + - - + + - + - - + +
timetime state GEO_TTL NAICS_TTLEMPEMP NAICS
20162016 01 Alabama Manufacturing234803234803 31-33
20162016 02 Alaska Manufacturing1217812178 31-33
20162016 56 Wyoming Manufacturing83778377 31-33
20162016 04 Arizona Manufacturing136946136946 31-33
20162016 05 Arkansas Manufacturing145733145733 31-33
20162016 06 California Manufacturing11198961119896 31-33
timetime us PSCODE_TTL GEO_TTLPRODVALPSCODEPRODVALPSCODE
20162016 1 Dog and cat food manufacturing United States2293333431111122933334311111
+

Business Dynamic Statistics +

+

Business +Dynamic Statistics documentation

+

Get the number of firms (FIRM) and number of net jobs +created from expanding/contracting and opening/closing establishments +during the last 12 months (NET_JOB_CREATION) in the +construction industry (NAICS = 23) for all years available +for Queens, New York.

+
+bds_queens <- getCensus(
+    name = "timeseries/bds",
+    vars = c("FIRM", "NET_JOB_CREATION", "NAICS_LABEL"),
+    region = "county:081",
+    regionin = "state:36",
+    YEAR = "*",
+    NAICS = 23)
+head(bds_queens)
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
statecountyFIRMNET_JOB_CREATIONNAICS_LABELYEARNAICS
3608117771929Construction197823
3608119072257Construction197923
3608119282175Construction198023
360811934-17Construction198123
3608119601575Construction198223
360812013687Construction198323
+
+

Get the same informtion for all states in 2021.

+
+bds_states <- getCensus(
+    name = "timeseries/bds",
+    vars = c("FIRM", "NET_JOB_CREATION", "NAICS_LABEL"),
+    region = "state:*",
+    time = 2021,
+    NAICS = 23)
+head(bds_states)
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
timestateFIRMNET_JOB_CREATIONNAICS_LABELNAICS
2021283526-1756Construction23
20212912237-659Construction23
2021304958650Construction23
20210173222142Construction23
20210669828-15909Construction23
2021315750101Construction23
+
+
+

Community Resiliency Estimates

Community @@ -1207,7 +1367,7 @@

Community Resiliency Estimates
getCensus(
     name = "cre",
     vintage = 2022,
@@ -1289,7 +1449,7 @@ 

County Business PatternsCounty Business Patterns documentation

Get employment data for the construction industry.

-
+
 cbp <- getCensus(
     name = "cbp",
     vintage = 2021,
@@ -1319,27 +1479,27 @@ 

County Business Patterns23 -04 -184434 -14289 +69 +994 +99 23 -05 -51809 -5939 +04 +184434 +14289 23 -06 -844489 -82744 +72 +26989 +2418 23 -08 -178752 -20299 +78 +2530 +163 23 @@ -1347,7 +1507,7 @@

County Business Patterns

Get the number of companies and employees at organizations with more than 1,000 employees (EMPSZES = 260).

-
+
 cbp_large_companies <- getCensus(
     name = "cbp",
     vintage = 2021,
@@ -1394,17 +1554,17 @@ 

County Business Patterns260 -06 -California -2816709 -1040 +09 +Connecticut +243212 +95 260 -08 -Colorado -365636 -144 +51 +Virginia +418542 +194 260 @@ -1416,7 +1576,7 @@

Zip Codes Business PatternsZip Codes Business Patterns documentation

-
+
 zbp_2018 <- getCensus(
     name = "zbp",
     vintage = 2018,
@@ -1426,44 +1586,44 @@ 

Zip Codes Business Patterns - + - + - + - + - + - + - + @@ -1479,7 +1639,7 @@

Nonemployer statistics

Get the number of nonemployer establishments by MSA for sector 54, Professional, scientific, and technical services.

-
+
 nonemp <- getCensus(
     name = "nonemp",
     vintage = 2021,
@@ -1499,7 +1659,7 @@ 

Nonemployer statistics

- + @@ -1507,42 +1667,42 @@

Nonemployer statistics

- + - + - + - + - + - + @@ -1562,7 +1722,7 @@

2020 Decennial CensusDP1_0024P) for metro and micropolitan statistical areas.

-
+
 dec_elderly <- getCensus(
     name = "dec/dp",
     vintage = 2020,
@@ -1619,7 +1779,7 @@ 

2020 Decennial CensusH9_001N) and the number of 1-person households (H9_002N) for counties in Maryland.

-
+
 dec <- getCensus(
     name = "dec/dhc",
     vintage = 2020,
@@ -1687,7 +1847,7 @@ 

2020 Decennial Census
+
 popgroup_values <- listCensusMetadata(
     name = "dec/ddhca",
     vintage = 2020, 
@@ -1738,7 +1898,7 @@ 

2020 Decennial CensusT01001_001N) of people who are Japanese alone or in any combination (POPGROUP code 3824) by state.

-
+
 dec_population <- getCensus(
     name = "dec/ddhca",
     vintage = 2020,
@@ -1814,7 +1974,7 @@ 

2010 Decennial Census
+
 data2010 <- getCensus(
     name = "dec/sf1",
     vintage = 2010,
@@ -1877,7 +2037,7 @@ 

2010 Decennial Census
+
 # Show variable metadata for the P2 group
 group_p2 <- listCensusMetadata(
     name = "dec/sf1",
@@ -1916,7 +2076,7 @@ 

2010 Decennial CensusP002005

- + @@ -1929,7 +2089,7 @@

2010 Decennial Census113591

- + @@ -1941,7 +2101,7 @@

2010 Decennial Census22111

- + @@ -1953,7 +2113,7 @@

2010 Decennial Census9836

- + @@ -1965,7 +2125,7 @@

2010 Decennial Census60502

- + @@ -1977,7 +2137,7 @@

2010 Decennial Census10854

- + @@ -1989,13 +2149,13 @@

2010 Decennial Census11182

- +
zip_codezip_code EMP ESTAB EMPSZES
9021090210 35324 2496 001
9021090210 0 1758 210
9021090210 0 322 220
9021090210 0 199 230
9021090210 0 137 241
9021090210 0 50 242
metropolitan_statistical_area_micropolitan_statistical_area NAMENESTABNESTAB NAICS2017_LABEL NAICS2017
10100 Aberdeen, SD Micro Area257257 Professional, scientific, and technical services 54
10140 Aberdeen, WA Micro Area422422 Professional, scientific, and technical services 54
10180 Abilene, TX Metro Area13501350 Professional, scientific, and technical services 54
10220 Ada, OK Micro Area237237 Professional, scientific, and technical services 54
10300 Adrian, MI Micro Area535535 Professional, scientific, and technical services 54
10420 Akron, OH Metro Area71907190 Professional, scientific, and technical services 54
P002006 NAMEP002001ERRP002001ERR
0 Madison, WI Metro AreaNANA
315800 Madisonville, KY Micro AreaNANA
368200 Oskaloosa, IA Micro AreaNANA
368600 Ottawa-Streator, IL Micro AreaNANA
369000 Ottumwa, IA Micro AreaNANA
369400 Owatonna, MN Micro AreaNANA

Get 2010 population by block group within a specific tract.

-
+
 tract_pop <- getCensus(
     name = "dec/sf1",
     vintage = 2010,
@@ -2067,7 +2227,7 @@ 

Decennial Census Self-Response Rat

Get self-response rates for the 2020 and 2010 Decennial Census by state, county, tract, place and more.

Get overall and internet repose rates for all counties.

-
+
 county_responses <- getCensus(
     name = "dec/responserate",
     vintage = 2020,
@@ -2146,7 +2306,7 @@ 

Decennial Census Self-Response Rat

Get response rates for places (cities, towns, etc) within New York state.

-
+
 ny_place_responses <- getCensus(
     name = "dec/responserate",
     vintage = 2020,
@@ -2225,7 +2385,7 @@ 

Decennial Census Self-Response Rat

Get final 2010 Decennial Census self-response rates.

-
+
 county_responses_2010 <- getCensus(
     name = "dec/responserate",
     vintage = 2010,
@@ -2288,7 +2448,7 @@ 

Decennial Census Surname Files
getCensus(
     name = "surname",
     vintage = 2010,
@@ -2311,88 +2471,88 @@ 

Decennial Census Surname Files NAME -COUNT +COUNT PROP100K -PCTWHITE -PCTBLACK -PCTAIAN -PCTAPI -PCTHISPANIC +PCTWHITE +PCTBLACK +PCTAIAN +PCTAPI +PCTHISPANIC PCT2PRACE -RANK +RANK ANDERSON -784404 +784404 265.92 -75.17 -18.93 -0.74 -0.61 -2.44 +75.17 +18.93 +0.74 +0.61 +2.44 2.11 -15 +15 BROWN -1437026 +1437026 487.16 -57.95 -35.6 -0.87 -0.51 -2.52 +57.95 +35.60 +0.87 +0.51 +2.52 2.55 -4 +4 DAVIS -1116357 +1116357 378.45 -62.2 -31.6 -0.82 -0.49 -2.44 +62.20 +31.60 +0.82 +0.49 +2.44 2.45 -8 +8 GARCIA -1166120 +1166120 395.32 -5.38 -0.45 -0.47 -1.41 -92.03 +5.38 +0.45 +0.47 +1.41 +92.03 0.26 -6 +6 GONZALEZ -841025 +841025 285.11 -4.03 -0.35 -0.14 -0.38 -94.97 +4.03 +0.35 +0.14 +0.38 +94.97 0.13 -13 +13 HARRIS -624252 +624252 211.63 -51.4 -42.39 -0.67 -0.47 -2.26 +51.40 +42.39 +0.67 +0.47 +2.26 2.80 -25 +25 @@ -2404,7 +2564,7 @@

Economic Census

Economic Census documentation

-
+
-
+
 ewks_2007 <- getCensus(
     name = "ewks",
     vintage = 2007,
@@ -2479,53 +2639,53 @@ 

Economic Census state -EMP +EMP OPTAX GEOTYPE -NAICS2007 +NAICS2007 01 -94051 +94051 A 2 -54 +54 01 -92759 +92759 T 2 -54 +54 01 -1292 +1292 Y 2 -54 +54 02 -12843 +12843 A 2 -54 +54 02 -12509 +12509 T 2 -54 +54 02 -334 +334 Y 2 -54 +54 @@ -2536,7 +2696,7 @@

Economic IndicatorsEconomic Indicators documentation

-
+
 eits <- getCensus(
     name = "timeseries/eits/resconst",
     vars = c("cell_value", "data_type_code", "time_slot_id", "error_data", "category_code", "seasonally_adj"),
@@ -2556,9 +2716,9 @@ 

Economic Indicators -cell_value +cell_value data_type_code -time_slot_id +time_slot_id error_data category_code seasonally_adj @@ -2567,9 +2727,9 @@

Economic Indicators -999 +999 SINGLE -0 +0 no APERMITS yes @@ -2577,9 +2737,9 @@

Economic Indicators1 -1354 +1354 TOTAL -0 +0 no APERMITS yes @@ -2587,9 +2747,9 @@

Economic Indicators1 -1482 +1482 TOTAL -0 +0 no APERMITS yes @@ -2597,9 +2757,9 @@

Economic Indicators1 -1437 +1437 TOTAL -0 +0 no APERMITS yes @@ -2607,9 +2767,9 @@

Economic Indicators1 -1417 +1417 TOTAL -0 +0 no APERMITS yes @@ -2617,9 +2777,9 @@

Economic Indicators1 -1496 +1496 TOTAL -0 +0 no APERMITS yes @@ -2637,7 +2797,7 @@

Health Insurance Insurance Statistics documentation

Get the uninsured rate by income group for each county for a single year.

-
+
 sahie <- getCensus(
     name = "timeseries/healthins/sahie",
     vars = c("NAME", "IPRCAT", "IPR_DESC", "PCTUI_PT"),
@@ -2656,7 +2816,7 @@ 

Health Insurance -time +time state county NAME @@ -2666,7 +2826,7 @@

Health Insurance -2021 +2021 01 001 Autauga County, AL @@ -2675,7 +2835,7 @@

Health Insurance 10.0 -2021 +2021 01 001 Autauga County, AL @@ -2684,7 +2844,7 @@

Health Insurance 18.8 -2021 +2021 01 001 Autauga County, AL @@ -2693,7 +2853,7 @@

Health Insurance 17.5 -2021 +2021 01 001 Autauga County, AL @@ -2702,7 +2862,7 @@

Health Insurance 20.3 -2021 +2021 01 001 Autauga County, AL @@ -2711,7 +2871,7 @@

Health Insurance 13.6 -2021 +2021 01 001 Autauga County, AL @@ -2724,7 +2884,7 @@

Health Insurance

Get the uninsured rate for a county from 2006 to the latest year available.

-
+
 sahie_annual <- getCensus(
     name = "timeseries/healthins/sahie",
     vars = c("NAME", "PCTUI_PT"),
@@ -2735,7 +2895,7 @@ 

Health Insurance
- + @@ -2743,112 +2903,112 @@

Health Insurance

- + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2860,7 +3020,7 @@

Health Insurance

Get the uninsured rate for non-elderly adults (AGECAT = 1) with incomes of 138 to 400% of the poverty line (IPRCAT = 5), by race and state.

-
+
 sahie_adults <- getCensus(
     name = "timeseries/healthins/sahie",
     vars = c("NAME", "PCTUI_PT", "RACECAT", "RACE_DESC"), 
@@ -2882,7 +3042,7 @@ 

Health Insurance

- + @@ -2893,7 +3053,7 @@

Health Insurance

- + @@ -2903,7 +3063,7 @@

Health Insurance

- + @@ -2913,7 +3073,7 @@

Health Insurance

- + @@ -2924,7 +3084,7 @@

Health Insurance

- + @@ -2934,7 +3094,7 @@

Health Insurance

- + @@ -2945,7 +3105,7 @@

Health Insurance

- + @@ -2968,7 +3128,7 @@

Household Pulse Survey -
+
 hps_state <- getCensus(
     name = "timeseries/hps",
     vars = c("NAME", "FOODSCARCE_RATE", "EXPENSE_RATE",
@@ -2990,7 +3150,7 @@ 

Household Pulse Survey

- + @@ -3001,7 +3161,7 @@

Household Pulse Survey

- + @@ -3011,7 +3171,7 @@

Household Pulse Survey63

- + @@ -3021,7 +3181,7 @@

Household Pulse Survey63

- + @@ -3031,7 +3191,7 @@

Household Pulse Survey63

- + @@ -3041,7 +3201,7 @@

Household Pulse Survey63

- + @@ -3051,7 +3211,7 @@

Household Pulse Survey63

- + @@ -3065,7 +3225,7 @@

Household Pulse Survey

Get the national food scarcity rate and expense difficulty rate for every survey period available since 2022.

-
+
 hps_us <- getCensus(
     name = "timeseries/hps",
     vars = c("FOODSCARCE_RATE", "EXPENSE_RATE",
@@ -3086,7 +3246,7 @@ 

Household Pulse Survey

- + @@ -3096,7 +3256,7 @@

Household Pulse Survey

- + @@ -3105,7 +3265,7 @@

Household Pulse Survey63

- + @@ -3114,7 +3274,7 @@

Household Pulse Survey62

- + @@ -3123,7 +3283,7 @@

Household Pulse Survey61

- + @@ -3132,7 +3292,7 @@

Household Pulse Survey60

- + @@ -3141,7 +3301,7 @@

Household Pulse Survey59

- + @@ -3150,7 +3310,7 @@

Household Pulse Survey58

- + @@ -3159,7 +3319,7 @@

Household Pulse Survey57

- + @@ -3168,7 +3328,7 @@

Household Pulse Survey56

- + @@ -3177,7 +3337,7 @@

Household Pulse Survey55

- + @@ -3186,7 +3346,7 @@

Household Pulse Survey54

- + @@ -3195,7 +3355,7 @@

Household Pulse Survey53

- + @@ -3204,7 +3364,7 @@

Household Pulse Survey52

- + @@ -3213,7 +3373,7 @@

Household Pulse Survey51

- + @@ -3222,7 +3382,7 @@

Household Pulse Survey50

- + @@ -3231,7 +3391,7 @@

Household Pulse Survey49

- + @@ -3240,7 +3400,7 @@

Household Pulse Survey48

- + @@ -3249,7 +3409,7 @@

Household Pulse Survey47

- + @@ -3258,7 +3418,7 @@

Household Pulse Survey46

- + @@ -3267,7 +3427,7 @@

Household Pulse Survey45

- + @@ -3276,7 +3436,7 @@

Household Pulse Survey44

- + @@ -3285,7 +3445,7 @@

Household Pulse Survey43

- + @@ -3294,7 +3454,7 @@

Household Pulse Survey42

- + @@ -3313,7 +3473,7 @@

International Data Base

Get Census Bureau projections of 2024 populations and life expectancy at birth by country.

-
+
 intl_pop <- getCensus(
     name = "timeseries/idb/5year",
     vars = c("NAME", "GENC", "POP", "E0"),
@@ -3322,53 +3482,53 @@ 

International Data Base

timetime state county NAME
20062006 06 037 Los Angeles County, CA 23.8
20072007 06 037 Los Angeles County, CA 23.1
20082008 06 037 Los Angeles County, CA 23.8
20092009 06 037 Los Angeles County, CA 24.9
20102010 06 037 Los Angeles County, CA 25.9
20112011 06 037 Los Angeles County, CA 24.8
20122012 06 037 Los Angeles County, CA 24.5
20132013 06 037 Los Angeles County, CA 23.7
20142014 06 037 Los Angeles County, CA 17.4
20152015 06 037 Los Angeles County, CA 12.5
20162016 06 037 Los Angeles County, CA 10.7
20172017 06 037 Los Angeles County, CA 10.1
20182018 06 037 Los Angeles County, CA 10.2
20192019 06 037 Los Angeles County, CA 11.1
20202020 06 037 Los Angeles County, CA 10.2
20212021 06 037 Los Angeles County, CA
timetime state NAME PCTUI_PT
20212021 01 Alabama 15.91
20212021 01 Alabama 14.11
20212021 01 Alabama 15.41
20212021 01 Alabama 40.41
20212021 01 Alabama 20.81
20212021 01 Alabama 14.8
timetime state NAME FOODSCARCE_RATE
20232023 01 Alabama 14.6
20232023 02 Alaska 15.3
20232023 04 Arizona 14.4
20232023 05 Arkansas 13.2
20232023 06 California 11.4
20232023 08 Colorado 11.5
timetime us FOODSCARCE_RATE EXPENSE_RATE
20232023 1 12.5 40.8
20232023 1 12.4 41.2
20232023 1 12.1 37.3
20232023 1 12.1 38.9
20232023 1 12.1 37.8
20232023 1 11.8 38.6
20232023 1 11.3 38.5
20232023 1 10.9 38.7
20232023 1 10.7 38.5
20232023 1 11.4 39.7
20232023 1 11.2 39.5
20222022 1 11.4 40.0
20222022 1 11.0 39.5
20222022 1 11.4 40.9
20222022 1 11.5 40.1
20222022 1 11.5 40.1
20222022 1 11.9 40.0
20222022 1 11.1 39.1
20222022 1 11.2 34.4
20222022 1 11.2 34.1
20222022 1 10.3 34.3
20222022 1 10.1 32.3
20222022 1 10.2 31.3
- + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3388,7 +3548,7 @@

International Trade
+
 imports <- getCensus(
     name = "timeseries/intltrade/imports/enduse",
     vars = c("CTY_CODE", "CTY_NAME", "GEN_VAL_MO", "CON_VAL_MO"),
@@ -3407,51 +3567,51 @@ 

International Tradetime

- - + + - - + + - - + + - - + + - - + + - - + + - - + +
timetime NAME GENCPOPPOP E0
20242024 Andorra AD8537085370 83.80
20242024 United Arab Emirates AE1003221310032213 79.94
20242024 Afghanistan AF4012155240121552 54.44
20242024 Antigua and Barbuda AG102634102634 78.28
20242024 Anguilla AI1941619416 82.61
20242024 Albania AL31071003107100 79.93
CTY_CODE CTY_NAMEGEN_VAL_MOCON_VAL_MOGEN_VAL_MOCON_VAL_MO
2024-01 - TOTAL FOR ALL COUNTRIES253796657727254565546221253796657727254565546221
2024-01 0003 EUROPEAN UNION46556315322462809139914655631532246280913991
2024-01 0014 PACIFIC RIM COUNTRIES79572147272792251732157957214727279225173215
2024-01 0017 CAFTA-DR2478595066247333834124785950662473338341
2024-01 0020 NAFTA71351448154712321559207135144815471232155920
2024-01 0021 TWENTY LATIN AMERICAN REPUBLICS50116067956504539863625011606795650453986362
@@ -3472,7 +3632,7 @@

Population Estimates
+
 popest <- getCensus(
     name = "pep/population",
     vintage = 2021,
@@ -3520,7 +3680,7 @@ 

Population Estimates
+
 popest_housing <- getCensus(
     name = "pep/housing",
     vintage = 2018,
@@ -3533,7 +3693,7 @@ 

Population Estimates state county -DATE_CODE +DATE_CODE DATE_DESC HUEST @@ -3541,42 +3701,42 @@

Population Estimates 02 195 -1 +1 4/1/2010 Census housing unit count 1994 02 195 -2 +2 4/1/2010 housing unit estimates base 1644 02 195 -3 +3 7/1/2010 housing unit estimate 1646 02 195 -4 +4 7/1/2011 housing unit estimate 1647 02 195 -5 +5 7/1/2012 housing unit estimate 1659 02 195 -6 +6 7/1/2013 housing unit estimate 1662 @@ -3589,7 +3749,7 @@

Population Projections

Population Projections documentation

-
+
 popproj <- getCensus(
     name = "pep/projpop",
     vintage = 2014,
@@ -3600,46 +3760,46 @@ 

Population Projections us -YEAR +YEAR POP -AGE +AGE 1 -2014 +2014 3971847 -0 +0 1 -2014 +2014 3957864 -1 +1 1 -2014 +2014 3972081 -2 +2 1 -2014 +2014 4003272 -3 +3 1 -2014 +2014 4001929 -4 +4 1 -2014 +2014 4002977 -5 +5 @@ -3655,7 +3815,7 @@

Poverty StatisticsCurrent Population Survey Poverty Statistics

Get national poverty rates by race since 1970.

-
+
 poverty <- getCensus(
     name = "timeseries/poverty/histpov2",
     vars = c("RACE", "RACE_LABEL", "PCTPOV"),
@@ -3665,54 +3825,54 @@ 

Current Population Survey
- + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +
timetime usRACERACE RACE_LABELPCTPOVPCTPOV
202212022 11 All races11.511.5
20222022 122 White alone10.510.5
20222022 144 White alone, not Hispanic8.68.6
20222022 166 Black alone or in combination17.017.0
20222022 177 Black alone17.117.1
20222022 199 Asian alone or in combination8.28.2
@@ -3722,7 +3882,7 @@

Current Population Survey

Small Area Income and Poverty Estimates (SAIPE)

Get poverty rate for children and overall for a single year.

-
+
 saipe <- getCensus(
     name = "timeseries/poverty/saipe",
     vars = c("NAME", "SAEPOVRT0_17_PT", "SAEPOVRTALL_PT"),
@@ -3732,7 +3892,7 @@ 

Small Area Income and Pov
- + @@ -3740,42 +3900,42 @@

Small Area Income and Pov

- + - + - + - + - + - + @@ -3786,7 +3946,7 @@

Small Area Income and Pov

Get the poverty rate for children and overall in a single county over time.

-
+
 saipe_years <- getCensus(
     name = "timeseries/poverty/saipe",
     vars = c("NAME", "SAEPOVRT0_17_PT", "SAEPOVRTALL_PT"),
@@ -3797,7 +3957,7 @@ 

Small Area Income and Pov

timetime state NAME SAEPOVRT0_17_PT
20222022 01 Alabama 21.8 16.2
20222022 02 Alaska 13.4 10.8
20222022 04 Arizona 16.0 12.5
20222022 05 Arkansas 21.2 16.3
20222022 06 California 15.3 12.2
20222022 08 Colorado 11.1
- + @@ -3806,7 +3966,7 @@

Small Area Income and Pov

- + @@ -3814,7 +3974,7 @@

Small Area Income and Pov

- + @@ -3822,7 +3982,7 @@

Small Area Income and Pov

- + @@ -3830,7 +3990,7 @@

Small Area Income and Pov

- + @@ -3838,7 +3998,7 @@

Small Area Income and Pov

- + @@ -3846,7 +4006,7 @@

Small Area Income and Pov

- + @@ -3863,7 +4023,7 @@

SAIPE School DistrictsGet the number (SAEPOV5_17V_PT) and rate (SAEPOVRAT5_17RV_PT) of children ages 5-17 living in poverty for unified school districts in Massachusetts.

-
+
 saipe_schools <- getCensus(
     name = "timeseries/poverty/saipe/schdist",
     vars = c("SD_NAME", "SAEPOV5_17V_PT", "SAEPOVRAT5_17RV_PT"),
@@ -3882,7 +4042,7 @@ 

SAIPE School Districts

- + @@ -3891,7 +4051,7 @@

SAIPE School Districts

- + @@ -3899,7 +4059,7 @@

SAIPE School Districts6.9

- + @@ -3907,7 +4067,7 @@

SAIPE School Districts9.5

- + - + @@ -3924,7 +4084,7 @@

SAIPE School Districts4.1

- + @@ -3932,7 +4092,7 @@

SAIPE School Districts6.8

- + @@ -3954,7 +4114,7 @@

Public Sector Statistics

Get expenditures for Public Elementary-Secondary School System Finances for Massachusetts.

-
+
 govs <- getCensus(
     name = "timeseries/govs",
     vars = c("SVY_COMP_LABEL", "AGG_DESC", "AGG_DESC_LABEL" ,"AMOUNT"),
@@ -3976,77 +4136,77 @@ 

Public Sector Statistics

- + - - - + + + - + - - - + + + - + - - - + + + - + - - - + + + - + - - - - - + + + + + - + - - - - - + + + + + - + - - - - - + + + + +
timetime state county NAME
20102010 12 001 Alachua County25.3
20112011 12 001 Alachua County23.5
20122012 12 001 Alachua County26.6
20132013 12 001 Alachua County25.7
20142014 12 001 Alachua County21.6
20152015 12 001 Alachua County
timetime state school_district_unified SD_NAME
20222022 25 00001 Quabbin School District
20222022 25 00002 Spencer-East Brookfield School District
20222022 25 00013 Southwick-Tolland-Granville Regional School @@ -3916,7 +4076,7 @@

SAIPE School Districts6.6

20222022 25 00067 Manchester Essex Regional School District
20222022 25 00542 Ayer-Shirley School District
20222022 25 00544 Monomoy Regional School District
timetime state SVY_COMP_LABEL AGG_DESC AGG_DESC_LABELAMOUNTSVY_COMPEXPENDTYPEAMOUNTSVY_COMPEXPENDTYPE
20212021 25 Annual Survey of School System Finance SS0601 Total current spending18965809060011896580961
20212021 25 Annual Survey of School System Finance SS0604 Current spending - Instruction - Total12362698060011236269861
20212021 25 Annual Survey of School System Finance SS0610 Current spending - All other functions4172450600141724561
20212021 25 Annual Survey of School System FinanceSS0701Current spending - Support services - Total618586606001SS0708Current spending - Support services - Other and +nonspecified support services41899761
20212021 25 Annual Survey of School System FinanceSS0702Current spending - Support services - Pupil support -services155101206001SS0701Current spending - Support services - Total618586661
20212021 25 Annual Survey of School System FinanceSS0703Current spending - Support services - Instructional -staff support services90209006001SS0702Current spending - Support services - Pupil support +services155101261
@@ -4060,7 +4220,7 @@

Quarterly Workforce Indicators
+
 qwi_counties <- getCensus(
     name = "timeseries/qwi/sa",
     vars = c("Emp", "EarnBeg"),
@@ -4071,51 +4231,51 @@ 

Quarterly Workforce Indicators - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -4125,7 +4285,7 @@

Quarterly Workforce Indicators
+
 qwi_time <- getCensus(
     name = "timeseries/qwi/sa",
     vars = c("Emp", "EarnBeg"),
@@ -4135,45 +4295,45 @@ 

Quarterly Workforce Indicators

EmpEarnBegEmpEarnBeg time state county
118823936118823936 2023-Q2 01 001
825713798825713798 2023-Q2 01 003
7157320871573208 2023-Q2 01 005
4735392947353929 2023-Q2 01 007
9140351391403513 2023-Q2 01 009
2267362322673623 2023-Q2 01 011
- - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -4183,7 +4343,7 @@

Quarterly Workforce Indicators
+
 qwi <- getCensus(
     name = "timeseries/qwi/sa",
     region = "state:02",
@@ -4211,52 +4371,52 @@ 

Quarterly Workforce Indicators

- - + + - + - + - + - - + + - + - + - + - - + + - + - + - + - - + + - + - + - + @@ -4270,7 +4430,7 @@

The Planning Database

Get population and 2010 Census mail return rates for block groups in Autauga County, AL.

-
+
 pdb <- getCensus(
     name = "pdb/blockgroup",
     vintage = 2018,
diff --git a/docs/articles/getting-started.html b/docs/articles/getting-started.html
index 059443d..9390c4b 100644
--- a/docs/articles/getting-started.html
+++ b/docs/articles/getting-started.html
@@ -357,7 +357,7 @@ 

Making a censusapi call

EmpEarnBegEmpEarnBeg time state
1881802351518818023515 2018-Q1 01
1891332347118913323471 2018-Q2 01
1911623343419116233434 2018-Q3 01
1908747368719087473687 2018-Q4 01
1913757359719137573597 2019-Q1 01
1918965357819189653578 2019-Q2 01
EmpsexEmpsex timequarterquarter agegrp ownercodefirmsizefirmsize seasonadjindustryindustry state
540540 2012-Q111 A07 A0511 U2121 02
481481 2012-Q111 A07 A0511 U2121 02
6262 2012-Q111 A07 A0511 U2121 02
- + @@ -366,7 +366,7 @@

Making a censusapi call

- + @@ -374,7 +374,7 @@

Making a censusapi call4912

- + @@ -382,7 +382,7 @@

Making a censusapi call20432

- + @@ -390,7 +390,7 @@

Making a censusapi call2150

- + @@ -398,7 +398,7 @@

Making a censusapi call1905

- + @@ -406,7 +406,7 @@

Making a censusapi call6145

- + @@ -440,7 +440,7 @@

Making a censusapi call

- + @@ -450,7 +450,7 @@

Making a censusapi call

- + @@ -459,7 +459,7 @@

Making a censusapi call13.4

- + @@ -468,7 +468,7 @@

Making a censusapi call17.1

- + @@ -477,7 +477,7 @@

Making a censusapi call16.8

- + @@ -486,7 +486,7 @@

Making a censusapi call17.4

- + @@ -495,7 +495,7 @@

Making a censusapi call15.6

- + @@ -525,7 +525,7 @@

Making a censusapi call

timetime state county NAME
20212021 01 001 Autauga County, AL
20212021 01 003 Baldwin County, AL
20212021 01 005 Barbour County, AL
20212021 01 007 Bibb County, AL
20212021 01 009 Blount County, AL
20212021 01 011 Bullock County, AL
timetime state county NAME
20212021 51 001 Accomack County, VA
20212021 51 001 Accomack County, VA
20212021 51 001 Accomack County, VA
20212021 51 001 Accomack County, VA
20212021 51 001 Accomack County, VA
20212021 51 001 Accomack County, VA
- + @@ -533,112 +533,112 @@

Making a censusapi call

- + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -708,7 +708,7 @@

Making a censusapi call

timetime state county NAME
20062006 13 089 DeKalb County, GA 19.0
20072007 13 089 DeKalb County, GA 17.2
20082008 13 089 DeKalb County, GA 22.5
20092009 13 089 DeKalb County, GA 22.9
20102010 13 089 DeKalb County, GA 25.8
20112011 13 089 DeKalb County, GA 23.9
20122012 13 089 DeKalb County, GA 21.7
20132013 13 089 DeKalb County, GA 22.1
20142014 13 089 DeKalb County, GA 19.4
20152015 13 089 DeKalb County, GA 16.9
20162016 13 089 DeKalb County, GA 15.3
20172017 13 089 DeKalb County, GA 15.9
20182018 13 089 DeKalb County, GA 17.1
20192019 13 089 DeKalb County, GA 16.9
20202020 13 089 DeKalb County, GA 14.0
20212021 13 089 DeKalb County, GA
- + @@ -718,7 +718,7 @@

Making a censusapi call

- + @@ -727,7 +727,7 @@

Making a censusapi call3

- + @@ -736,7 +736,7 @@

Making a censusapi call3

- + @@ -745,7 +745,7 @@

Making a censusapi call3

- + @@ -754,7 +754,7 @@

Making a censusapi call3

- + @@ -763,7 +763,7 @@

Making a censusapi call3

- + @@ -772,7 +772,7 @@

Making a censusapi call3

- + @@ -781,7 +781,7 @@

Making a censusapi call3

- + @@ -790,7 +790,7 @@

Making a censusapi call3

- + @@ -799,7 +799,7 @@

Making a censusapi call3

- + @@ -808,7 +808,7 @@

Making a censusapi call3

- + @@ -817,7 +817,7 @@

Making a censusapi call3

- + diff --git a/docs/news/index.html b/docs/news/index.html index 38e194a..4cf727b 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -69,6 +69,12 @@

API keysgetCensus() 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.
  • +
  • New has_api_key() helper function detects if there is a stored Census Bureau API key in the Renviron, intended mainly for internal use.
  • + +
    +

    Variable typing

    +
    • +getCensus() uses improved logic to automatically convert columns that contain all numbers to numeric, unless the column name is in a specific list of geography names or other string type columns. Use convert_variable = FALSE to leave all columns as characters.

    Metadata

    @@ -84,12 +90,6 @@

    Metadata -

    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.
    • Examples are updated to use newly released datasets.
    • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index c587515..4a99a9f 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-02T18:10Z +last_built: 2024-04-05T16:50Z urls: reference: https://www.hrecht.com/censusapi/reference article: https://www.hrecht.com/censusapi/articles diff --git a/docs/search.json b/docs/search.json index 7f9d31c..826a67e 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 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":""}] +[{"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":"business-dynamic-statistics","dir":"Articles","previous_headings":"","what":"Business Dynamic Statistics","title":"censusapi examples","text":"Business Dynamic Statistics documentation Get number firms (FIRM) number net jobs created expanding/contracting opening/closing establishments last 12 months (NET_JOB_CREATION) construction industry (NAICS = 23) years available Queens, New York. Get informtion states 2021.","code":"bds_queens <- getCensus( name = \"timeseries/bds\", vars = c(\"FIRM\", \"NET_JOB_CREATION\", \"NAICS_LABEL\"), region = \"county:081\", regionin = \"state:36\", YEAR = \"*\", NAICS = 23) head(bds_queens) bds_states <- getCensus( name = \"timeseries/bds\", vars = c(\"FIRM\", \"NET_JOB_CREATION\", \"NAICS_LABEL\"), region = \"state:*\", time = 2021, NAICS = 23) head(bds_states)"},{"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. 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":"variable-typing-0-9-0","dir":"Changelog","previous_headings":"New features","what":"Variable typing","title":"censusapi 0.9.0 (development verison)","text":"getCensus() uses improved logic automatically convert columns contain numbers numeric, unless column name specific list geography names string type columns. Use convert_variable = FALSE leave columns characters.","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":"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/vignettes/articles/example-list.Rmd b/vignettes/articles/example-list.Rmd index 68847f4..e40acfb 100644 --- a/vignettes/articles/example-list.Rmd +++ b/vignettes/articles/example-list.Rmd @@ -170,6 +170,34 @@ asm_product <- getCensus( PSCODE = 311111) head(asm_product) ``` + +## Business Dynamic Statistics + +[Business Dynamic Statistics documentation](https://www.census.gov/data/developers/data-sets/business-dynamics.html) + +Get the number of firms (`FIRM`) and number of net jobs created from expanding/contracting and opening/closing establishments during the last 12 months (`NET_JOB_CREATION`) in the construction industry (`NAICS = 23`) for all years available for Queens, New York. +```{r} +bds_queens <- getCensus( + name = "timeseries/bds", + vars = c("FIRM", "NET_JOB_CREATION", "NAICS_LABEL"), + region = "county:081", + regionin = "state:36", + YEAR = "*", + NAICS = 23) +head(bds_queens) +``` + +Get the same informtion for all states in 2021. +```{r} +bds_states <- getCensus( + name = "timeseries/bds", + vars = c("FIRM", "NET_JOB_CREATION", "NAICS_LABEL"), + region = "state:*", + time = 2021, + NAICS = 23) +head(bds_states) +``` + ## Community Resiliency Estimates [Community Resilience Estimates documentation](https://www.census.gov/data/developers/data-sets/community-resilience-estimates.html) @@ -396,6 +424,7 @@ ewks_2012 <- getCensus( region = "state:*", NAICS2012 = 54) head(ewks_2012) + ewks_2007 <- getCensus( name = "ewks", vintage = 2007,

    timetime state county NAME
    20102010 06 037 Los Angeles County, CA
    20112011 06 037 Los Angeles County, CA
    20122012 06 037 Los Angeles County, CA
    20132013 06 037 Los Angeles County, CA
    20142014 06 037 Los Angeles County, CA
    20152015 06 037 Los Angeles County, CA
    20162016 06 037 Los Angeles County, CA
    20172017 06 037 Los Angeles County, CA
    20182018 06 037 Los Angeles County, CA
    20192019 06 037 Los Angeles County, CA
    20202020 06 037 Los Angeles County, CA
    20212021 06 037 Los Angeles County, CA