diff --git a/DESCRIPTION b/DESCRIPTION index dbcc84e..cc7f4fd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -14,7 +14,8 @@ LazyData: true RoxygenNote: 7.3.1 Imports: httr, - jsonlite + jsonlite, + rlang Suggests: knitr, rmarkdown diff --git a/NAMESPACE b/NAMESPACE index e2f11fa..c5d7f8e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ export(getCensus) export(getFunction) +export(get_api_key) export(listCensusApis) export(listCensusMetadata) export(makeVarlist) diff --git a/NEWS.md b/NEWS.md index 79cc297..6dca25e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -5,6 +5,8 @@ ## New features * `getCensus()` no longer requires `key`, the use of a Census Bureau API key. Users are still encouraged to register for and use an API key because the Census Bureau may rate limit IP addresses, but it is not required. (#87) +* New `get_api_key()` helper function retrieves the value of a user's stored Census Bureau API key from a saved environment variable or provides a warning message if none is found. + * `listCensusApis()` now has optional `name` and `vintage` parameters to get metadata for a subset of datasets or a single dataset. (#103) ```R diff --git a/R/getcensus_functions.R b/R/getcensus_functions.R index 86ce57b..5844a90 100644 --- a/R/getcensus_functions.R +++ b/R/getcensus_functions.R @@ -258,13 +258,7 @@ getCensus <- # Check for key in environment, print a message if one is not provided or in environment if (is.null(key)) { - if (Sys.getenv("CENSUS_KEY") != "") { - key <- Sys.getenv("CENSUS_KEY") - } else if (Sys.getenv("CENSUS_API_KEY") != "") { - key <- Sys.getenv("CENSUS_API_KEY") - } else { - message("You are not using a Census API key. Using a key is recommended but not required.\nThe Census Bureau may limit your daily requests.\nYou can register for an API key at https://api.census.gov/data/key_signup.html\nLearn more at https://www.hrecht.com/censusapi/articles/getting-started.html.") - } + key <- get_api_key() } apiurl <- constructURL(name, vintage) diff --git a/R/metadata_functions.R b/R/metadata_functions.R index 6bd788e..5284a9a 100644 --- a/R/metadata_functions.R +++ b/R/metadata_functions.R @@ -131,12 +131,15 @@ listCensusApis <- function(name = NULL, #' @param name API programmatic name - e.g. acs/acs5. Use `listCensusApis()` to #' see valid dataset names. #' @param vintage Vintage (year) of dataset. Not required for timeseries APIs. -#' @param type Type of metadata to return. Options are: "variables" (default) - -#' list of variable names and descriptions for the dataset. "geographies" - -#' available geographies. "groups" - available variable groups. Only available -#' for some datasets. "values" - encoded value labels for a given variable. -#' Pair with "variable_name". This information is only available for some -#' datasets. +#' @param type Type of metadata to return. Options are: +#' +#' * "variables" (default) - list of variable names and descriptions +#' for the dataset. +#' * "geographies" - available geographies. +#' * "groups" - available variable groups. Only available +#' for some datasets. +#' * "values" - encoded value labels for a given variable. Pair with +#' "variable_name". Only available for some datasets. #' @param group An optional variable group code, used to return metadata for a #' specific group of variables only. Variable groups are not used for all #' APIs. diff --git a/_pkgdown.yaml b/_pkgdown.yaml index f75e8bb..1f2665c 100644 --- a/_pkgdown.yaml +++ b/_pkgdown.yaml @@ -39,6 +39,7 @@ reference: - makeVarlist - title: "Helpers" contents: + - get_api_key - fips redirects: diff --git a/docs/articles/example-list.html b/docs/articles/example-list.html index 695c037..c041d42 100644 --- a/docs/articles/example-list.html +++ b/docs/articles/example-list.html @@ -825,33 +825,6 @@

Annual Survey of EntrepreneursTotal for all sectors 0000 All firms -LZ -Jointly owned and equally operated by spouses -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 - - -1 -United States -Total for all sectors -0000 -All firms MA Jointly owned but primarily operated by male spouse @@ -874,6 +847,33 @@

Annual Survey of Entrepreneurs3.0 3.5 + +1 +United States +Total for all sectors +0000 +All firms +LZ +Jointly owned and equally operated by spouses +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 + 1 United States @@ -1319,27 +1319,27 @@

County Business Patterns23 -04 -184434 -14289 +30 +30361 +6314 23 -05 -51809 -5939 +32 +92895 +5651 23 -06 -844489 -82744 +04 +184434 +14289 23 -08 -178752 -20299 +16 +54863 +9311 23 @@ -1387,26 +1387,26 @@

County Business Patterns260 -09 -Connecticut -243212 -95 +05 +Arkansas +114638 +67 260 -10 -Delaware -57660 -29 -260 - - 11 District of Columbia 84070 30 260 + +26 +Michigan +621672 +252 +260 + @@ -1749,11 +1749,11 @@

2020 Decennial Census -----+++++ @@ -1785,23 +1785,23 @@

2020 Decennial Census3824

- - - + + + - - - + + + - - - + + + @@ -2451,16 +2451,16 @@

Economic Census54

- - - + + + - - + + @@ -2567,63 +2567,63 @@

Economic Indicators -

- + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - - + + - + - + @@ -2743,116 +2743,116 @@

Health Insurance

- + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +
state
24Maryland1746405Arkansas3825 Japanese alone or in any combination 3824
37North Carolina2048406California469915 Japanese alone or in any combination 3824
19Iowa417908Colorado31916 Japanese alone or in any combination 3824
0217328T084616Y 02 54
02320Y17328T 02 54
999SINGLE966MULTI 0 noAPERMITSUNDERCONST yes2023-122023-04 1
1354TOTAL978MULTI 0 noAPERMITSUNDERCONST yes2023-012023-05 1
1482TOTAL991MULTI 0 noAPERMITSUNDERCONST yes2023-022023-06 1
1437TOTAL1001MULTI 0 noAPERMITSUNDERCONST yes2023-032023-07 1
1417TOTAL1000MULTI 0 noAPERMITSUNDERCONST yes2023-042023-08 1
1496TOTAL991MULTI 0 noAPERMITSUNDERCONST yes2023-052023-09 1
20062015 06 037 Los Angeles County, CA23.812.5
20072016 06 037 Los Angeles County, CA23.110.7
20082017 06 037 Los Angeles County, CA23.810.1
20092018 06 037 Los Angeles County, CA24.910.2
20102019 06 037 Los Angeles County, CA25.911.1
20112020 06 037 Los Angeles County, CA24.810.2
20122021 06 037 Los Angeles County, CA24.510.1
20132006 06 037 Los Angeles County, CA23.723.8
20142007 06 037 Los Angeles County, CA17.423.1
20152008 06 037 Los Angeles County, CA12.523.8
20162009 06 037 Los Angeles County, CA10.724.9
20172010 06 037 Los Angeles County, CA10.125.9
20182011 06 037 Los Angeles County, CA10.224.8
20192012 06 037 Los Angeles County, CA11.124.5
20202013 06 037 Los Angeles County, CA10.223.7
20212014 06 037 Los Angeles County, CA10.117.4
@@ -4020,10 +4020,9 @@

Public Sector Statistics2021 25 Annual Survey of School System Finance -SS0708 -Current spending - Support services - Other and -nonspecified support services -418997 +SS0701 +Current spending - Support services - Total +6185866 06 001 @@ -4031,9 +4030,10 @@

Public Sector Statistics2021 25 Annual Survey of School System Finance -SS0701 -Current spending - Support services - Total -6185866 +SS0702 +Current spending - Support services - Pupil support +services +1551012 06 001 @@ -4041,10 +4041,10 @@

Public Sector Statistics2021 25 Annual Survey of School System Finance -SS0702 -Current spending - Support services - Pupil support -services -1551012 +SS0703 +Current spending - Support services - Instructional +staff support services +902090 06 001 diff --git a/docs/articles/getting-started.html b/docs/articles/getting-started.html index 5d3f100..86ded8c 100644 --- a/docs/articles/getting-started.html +++ b/docs/articles/getting-started.html @@ -87,14 +87,11 @@ -

censusapi is a lightweight package that retrieves data -from the U.S. Census Bureau’s APIs. More than -1,000 Census API -endpoints are available, including the Decennial Census, American -Community Survey, Poverty Statistics, Population Estimates, and Census -microdata. This package is designed to let you get data from all of -those APIs using the same main functions and syntax for every -dataset.

+

censusapi is a lightweight package that helps you +retrieve data from the U.S. Census Bureau’s 1,600 API +endpoints using one simple function, getCensus(). +Additional functions provide information about what datasets are +available and how to use them.

This package returns the data as-is with the original variable names created by the Census Bureau and any quirks inherent in the data. Each dataset is a little different. Some are documented thoroughly, others @@ -108,94 +105,35 @@

API key setupsign up online to receive a key, which will be sent to your provided email address.

If you save the key with the name CENSUS_KEY or -CENSUS_API_KEY in your .Renviron file, +CENSUS_API_KEY in your Renviron file, censusapi will use it by default without any extra work on your part.

To save your API key, within R, run:

-# Add key to .Renviron
+# 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
-Sys.getenv("CENSUS_KEY")
+get_api_key()

In some instances you might not want to put your key in your .Renviron - for example, if you’re on a shared school computer. You can always choose to manually set key = "PASTEYOURKEYHERE" as an argument in getCensus() if you prefer.

-

Finding your API -

-

To get started, load the censusapi library.

- -

To see a current table of every available endpoint, -uselistCensusApis(). This data frame includes useful -information for making your API call, including the dataset’s name, -description and title, as well as a contact email for questions about -the underlying data.

-
-apis <- listCensusApis()
-colnames(apis)
-
#>  [1] "title"       "name"        "vintage"     "type"        "temporal"   
-#>  [6] "spatial"     "url"         "modified"    "description" "contact"
-

This returns useful information about each endpoint.

-
    -
  • title: Short written description of the dataset
  • -
  • name: Programmatic name of the dataset, to be used with -censusapi functions
  • -
  • vintage: Year of the survey, for use with microdata and aggregate -datasets
  • -
  • type: Dataset type, which is either Aggregate, Microdata, or -Timeseries
  • -
  • temporal: Time period of the dataset - only documented -sometimes
  • -
  • url: Base URL of the endpoint
  • -
  • modified: Date last modified
  • -
  • description: Long written description of the dataset
  • -
  • contact: Email address for specific questions about the Census -Bureau survey
  • -
-
-

Dataset types -

-

There are three types of datasets included in the Census Bureau API -universe: aggregate, microdata, and timeseries. These type names were -defined by the Census Bureau and are included as a column in -listCensusApis().

-
-table(apis$type)
-
#> 
-#>  Aggregate  Microdata Timeseries 
-#>        624        894         81
-

Most users will work with summary data, either aggregate or -timeseries. Summary data contains pre-calculated numbers or percentages -for a given statistic — like the number of children in a state or the -median household income. The examples below and in the broader list -of censusapi examples use summary data.

-

Aggregate datasets, like the American Community Survey or Decennial -Census, include data for only one time period (a vintage), -usually one year. Datasets like the American Community Survey contain -thousands of these pre-computed variables.

-

Timeseries datasets, including the Small Area Income and Poverty -Estimates, the Quarterly Workforce Estimates, and International Trade -statistics, allow users to query data for more than one time period in a -single API call.

-

Microdata contains the individual-level responses for a survey for -use in custom analysis. One row represents one person. Only advanced -analysts will want to use microdata. Learn more about what microdata is -and how to use it with censusapi in Accessing -microdata.

-
-
-
-

Using getCensus +

Basic usage

The main function in censusapi is getCensus(), which makes an API call to a given endpoint @@ -212,11 +150,10 @@

Using getCensusvars: a list of variables to retrieve
  • region: the geography level to retrieve, such as state -or county, required for most endpoints
  • +or county, required for nearly all endpoints

    Some APIs have additional required or optional arguments, like -time or monthly for some timeseries datasets. -Check the specific documentation +time for some timeseries datasets. Check the specific documentation for your API and explore its metadata with listCensusMetadata() to see what options are allowed.

    Let’s walk through an example getting uninsured rates using the Small @@ -230,8 +167,10 @@

    Choosing variableslistCensusMetadata() to get information about an API’s variable and geography options. Let’s see what variables are available in the SAHIE API:

    -
    -sahie_vars <- listCensusMetadata(
    +
    +library(censusapi)
    +
    +sahie_vars <- listCensusMetadata(
         name = "timeseries/healthins/sahie", 
         type = "variables")
     
    @@ -245,7 +184,7 @@ 

    Choosing variables#> [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"

    -
    +
     
    -
    -

    Making a censusapi call -

    +
    +

    Making a censusapi call +

    First, using getCensus(), let’s get the percent -(PCTUI_PT) and number (NUI_PT) of people -uninsured, using the wildcard star (*) to retrieve data for all +(PCTUI_PT) and number (NUI_PT) of people who +are uninsured, using the wildcard star (*) to retrieve data for all counties.

    -
    +
     sahie_counties <- getCensus(
         name = "timeseries/healthins/sahie",
         vars = c("NAME", "PCTUI_PT", "NUI_PT"), 
    @@ -482,14 +420,14 @@ 

    Making a censusapi callregion to specify county-level results and regionin to filter to Virginia, state code 51. We’ll get uninsured rates by income group, IPRCAT.

    -
    +
     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(sahie_virginia, head = 12L)
    @@ -576,7 +514,7 @@

    Making a censusapi callCensus Bureau website.

    -
    +
     sahie_years <- getCensus(
         name = "timeseries/healthins/sahie",
         vars = c("NAME", "PCTUI_PT"), 
    @@ -595,129 +533,170 @@ 

    Making a censusapi call

    - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +
    20062015 13 089 DeKalb County, GA19.016.9
    20072016 13 089 DeKalb County, GA17.215.3
    20082017 13 089 DeKalb County, GA22.515.9
    20092018 13 089 DeKalb County, GA22.917.1
    20102019 13 089 DeKalb County, GA25.816.9
    20112020 13 089 DeKalb County, GA23.914.0
    20122021 13 089 DeKalb County, GA21.714.2
    20132006 13 089 DeKalb County, GA22.119.0
    20142007 13 089 DeKalb County, GA19.417.2
    20152008 13 089 DeKalb County, GA16.922.5
    20162009 13 089 DeKalb County, GA15.322.9
    20172010 13 089 DeKalb County, GA15.925.8
    20182011 13 089 DeKalb County, GA17.123.9
    20192012 13 089 DeKalb County, GA16.921.7
    20202013 13 089 DeKalb County, GA14.022.1
    20212014 13 089 DeKalb County, GA14.219.4

    We can also filter the data by income group using the -IPRCAT variable again. IPRCAT = 3 represents -<=138% of the federal poverty line. That is the threshold for Medicaid +IPRCAT variable. See the possible values of +IPRCAT using listCensusMetadata().

    +

    IPRCAT = 3 represents <=138% of the federal poverty +line. That is the threshold for Medicaid eligibility in states that have expanded it under the Affordable Care Act.

    +
    +listCensusMetadata(
    +    name = "timeseries/healthins/sahie",
    +    type = "values",
    +    variable = "IPRCAT")
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    codelabel
    0All Incomes
    1Less than or Equal to 200% of Poverty
    2Less than or Equal to 250% of Poverty
    3Less than or Equal to 138% of Poverty
    4Less than or Equal to 400% of Poverty
    5138% to 400% Poverty
    +

    Getting this data for Los Angeles county (fips code 06037) we can see the dramatic decrease in the uninsured rate in this income group after California expanded Medicaid.

    - +

    +
    +

    Finding your API +

    +

    What if you don’t already know your dataset’s name? To +see a current table of every available endpoint, use +listCensusApis(). This data frame includes useful +information for making your API call, including the dataset’s name, +vintage if applicable, description, and title.

    +
    +apis <- listCensusApis()
    +colnames(apis)
    +
    #>  [1] "title"       "name"        "vintage"     "type"        "temporal"   
    +#>  [6] "spatial"     "url"         "modified"    "description" "contact"
    +

    The columns included are:

    +
      +
    • title: Short written description of the dataset.
    • +
    • name: Programmatic name of the dataset, to be used with +censusapi functions.
    • +
    • vintage: Year of the survey, for use with microdata and aggregate +datasets.
    • +
    • type: Dataset type, which is either “Aggregate”, “Microdata”, or +“Timeseries”.
    • +
    • temporal: Time period of the dataset. Warning: not always +documented.
    • +
    • spatial: Spatial region of the dataset. Warning: not always +documented.
    • +
    • url: Base URL of the dataset endpoint.
    • +
    • modified: Date last modified. Warning: sometimes out of date.
    • +
    • description: Long written description of the dataset.
    • +
    • contact: Email address for specific questions about the Census +Bureau survey.
    • +
    +

    You can also get information on a subset of datasets using the +optional name and/or vintage parameters. For +example, get information about 2020 Decennial Census datasets.

    +
    +dec_apis <- listCensusApis(name = "dec", vintage = 2020)
    +dec_apis[, 1:6]
    --+-----++++ - - - - - - - - + + + + + + - - - - - - - - + + + + + + - - - - - - - - + + + + + + - - - - - - - - + + + + + + - - - - - - - - + + + + + + - - - - - - - - + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    timestatecountyNAMEPCTUI_PTNUI_PTAGECATAGE_DESCtitlenamevintagetypetemporalspatial
    202106037Los Angeles County, CA10.18344240Under 65 yearsDecennial Census: 118th Congressional District Summary +Filedec/cd1182020Aggregate2020/2020US
    202106037Los Angeles County, CA12.3768094118 to 64 yearsDecennial Census of Island Areas: American Samoa +Detailed Crosstabulationsdec/crosstabas2020Aggregate2020/2020American Samoa
    202106037Los Angeles County, CA11.7370339240 to 64 yearsDecennial Census of Island Areas: Guam Detailed +Crosstabulationsdec/crosstabgu2020Aggregate2020/2020Guam
    202106037Los Angeles County, CA10.2190193350 to 64 yearsDecennial Census of Island Areas: Commonwealth of the +Northern Mariana Islands Detailed Crosstabulationsdec/crosstabmp2020Aggregate2020/2020Northern Mariana Islands
    202106037Los Angeles County, CA3.5757714Under 19 yearsDecennial Census of Island Areas: U.S. Virgin Islands +Detailed Crosstabulationsdec/crosstabvi2020Aggregate2020/2020U.S. Virgin Islands
    202106037Los Angeles County, CA12.5737126521 to 64 yearsDecennial Census: Detailed Demographic and Housing +Characteristics File Adec/ddhca2020Aggregate2020/2020United States
    Decennial Census: Demographic and Housing +Characteristicsdec/dhc2020Aggregate2020/2020United States
    Decennial Census of Island Areas: American Samoa +Demographic and Housing Characteristicsdec/dhcas2020Aggregate2020/2020American Samoa
    Decennial Census of Island Areas: Guam Demographic and +Housing Characteristicsdec/dhcgu2020Aggregate2020/2020Guam
    Decennial Census of Island Areas: Commonwealth of the +Northern Mariana Islands Demographic and Housing Characteristicsdec/dhcmp2020Aggregate2020/2020Commonwealth of the Northern Mariana Islands
    Decennial Census of Island Areas: U.S. Virgin Islands +Demographic and Housing Characteristicsdec/dhcvi2020Aggregate2020/2020U.S. Virgin Islands
    Decennial Census: Demographic Profiledec/dp2020Aggregate2020/2020United States
    Decennial Census of Island Areas: American Samoa +Demographic Profiledec/dpas2020Aggregate2020/2020United States
    Decennial Census of Island Areas: Guam Demographic +Profiledec/dpgu2020Aggregate2020/2020United States
    2020 Commonwealth of the Northern Mariana Islands +Demographic Profiledec/dpmp2020Aggregate2020/2020United States
    Decennial Census of Island Areas: U.S. Virgin Islands +Demographic Profiledec/dpvi2020Aggregate2020/2020United States
    Decennial Census: Decennial Post-Enumeration +Surveydec/pes2020Aggregate2020/2020US
    Decennial Census: Redistricting Data (PL 94-171)dec/pl2020Aggregate2020/2020United States
    Decennial Census: Decennial Self-Response Ratedec/responserate2020AggregateNANA
    +
    +

    Dataset types +

    +

    There are three types of datasets included in the Census Bureau API +universe: aggregate, microdata, and timeseries. These type names were +defined by the Census Bureau and are included as a column in +listCensusApis().

    +
    +table(apis$type)
    +
    #> 
    +#>  Aggregate  Microdata Timeseries 
    +#>        624        895         81
    +

    Most users will work with summary data, either aggregate or +timeseries. Summary data contains pre-calculated numbers or percentages +for a given statistic — like the number of children in a state or the +median household income. The examples below and in the broader list +of censusapi examples use summary data.

    +

    Aggregate datasets, like the American Community Survey or Decennial +Census, include data for only one time period (a vintage), +usually one year. Datasets like the American Community Survey contain +thousands of these pre-computed variables.

    +

    Timeseries datasets, including the Small Area Income and Poverty +Estimates, the Quarterly Workforce Estimates, and International Trade +statistics, allow users to query data over time in a single API +call.

    +

    Microdata contains the individual-level responses for a survey for +use in custom analysis. One row represents one person. Only advanced +analysts will want to use microdata. Learn more about what microdata is +and how to use it with censusapi in Accessing +microdata.

    +

    Variable groups

    -

    For some surveys, particularly the American Community Survey and +

    For some surveys, including the American Community Survey and Decennial Census, you can get many related variables at once using a variable group. These groups are defined by the Census Bureau. In some other data tools, like data.census.gov, this concept is referred to as a table.

    Some groups have several dozen variables, others just have a few. As -an example, we’ll get the estimate, margin of error and annotations for -median household income in the past 12 months for counties in Alabama -using group B19013.

    +an example, we’ll use the American Community Survey to get the estimate, +margin of error and annotations for median household income in the past +12 months for Census places (cities, towns, etc) in Alabama using group +B19013.

    First, see descriptions of the variables in group B19013:

    -+--++ - + @@ -1077,63 +1222,63 @@

    Variable groups

    - - + + - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - + - - + +
    statecountyplace B19013_001E B19013_001EA B19013_001M
    01001683150010029263 NA49412846 NA0500000US01001Autauga County, Alabama1600000US0100100Abanda CDP, Alabama
    01003710390012435147 NA237415376 NA0500000US01003Baldwin County, Alabama1600000US0100124Abbeville city, Alabama
    01005397120046058631 NA328913426 NA0500000US01005Barbour County, Alabama1600000US0100460Adamsville city, Alabama
    01007506690048447188 NA82606288 NA0500000US01007Bibb County, Alabama1600000US0100484Addison town, Alabama
    01009574400067653929 NA330835679 NA0500000US01009Blount County, Alabama1600000US0100676Akron town, Alabama
    01011361360082089423 NA47316760 NA0500000US01011Bullock County, Alabama1600000US0100820Alabaster city, Alabama
    diff --git a/docs/news/index.html b/docs/news/index.html index 1b224fc..0a18d1a 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -65,6 +65,7 @@

    Breaking changes

    New features

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

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

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

     
    diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml
    index 1dcdf2b..49bc0f2 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-03-27T21:01Z
    +last_built: 2024-04-01T14:24Z
     urls:
       reference: https://www.hrecht.com/censusapi/reference
       article: https://www.hrecht.com/censusapi/articles
    diff --git a/docs/reference/getCensus.html b/docs/reference/getCensus.html
    index 5de623a..5d316e1 100644
    --- a/docs/reference/getCensus.html
    +++ b/docs/reference/getCensus.html
    @@ -149,7 +149,7 @@ 

    Arguments

    Examples

    -
    # \dontrun{
    +    
    if (FALSE) {
     # 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(
    @@ -159,13 +159,6 @@ 

    Examples 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. @@ -175,111 +168,6 @@

    Examples vars = "group(B08301)", region = "state:*") head(acs_group) -#> state B08301_001E B08301_001EA B08301_001M B08301_001MA B08301_002E -#> 1 01 2183677 <NA> 9550 <NA> 1985736 -#> 2 02 351067 <NA> 2187 <NA> 274263 -#> 3 04 3244419 <NA> 9451 <NA> 2610395 -#> 4 05 1304084 <NA> 6929 <NA> 1177402 -#> 5 06 18353469 <NA> 22043 <NA> 14313290 -#> 6 08 3006848 <NA> 8149 <NA> 2304559 -#> B08301_002EA B08301_002M B08301_002MA B08301_003E B08301_003EA B08301_003M -#> 1 <NA> 10017 <NA> 1808631 <NA> 9646 -#> 2 <NA> 2820 <NA> 231484 <NA> 3143 -#> 3 <NA> 12006 <NA> 2285920 <NA> 12162 -#> 4 <NA> 6616 <NA> 1051964 <NA> 6428 -#> 5 <NA> 23546 <NA> 12561068 <NA> 25223 -#> 6 <NA> 9026 <NA> 2062480 <NA> 8986 -#> B08301_003MA B08301_004E B08301_004EA B08301_004M B08301_004MA B08301_005E -#> 1 <NA> 177105 <NA> 4751 <NA> 137578 -#> 2 <NA> 42779 <NA> 2105 <NA> 32397 -#> 3 <NA> 324475 <NA> 5200 <NA> 242556 -#> 4 <NA> 125438 <NA> 3531 <NA> 94684 -#> 5 <NA> 1752222 <NA> 14058 <NA> 1269237 -#> 6 <NA> 242079 <NA> 5338 <NA> 180493 -#> B08301_005EA B08301_005M B08301_005MA B08301_006E B08301_006EA B08301_006M -#> 1 <NA> 4204 <NA> 24358 <NA> 1675 -#> 2 <NA> 1886 <NA> 5712 <NA> 684 -#> 3 <NA> 4612 <NA> 48889 <NA> 1844 -#> 4 <NA> 2975 <NA> 18415 <NA> 1284 -#> 5 <NA> 10568 <NA> 281935 <NA> 5811 -#> 6 <NA> 4522 <NA> 37353 <NA> 1984 -#> B08301_006MA B08301_007E B08301_007EA B08301_007M B08301_007MA B08301_008E -#> 1 <NA> 8791 <NA> 1005 <NA> 2998 -#> 2 <NA> 2977 <NA> 646 <NA> 1039 -#> 3 <NA> 18286 <NA> 1327 <NA> 10171 -#> 4 <NA> 7226 <NA> 913 <NA> 2976 -#> 5 <NA> 109445 <NA> 3668 <NA> 61640 -#> 6 <NA> 14757 <NA> 1317 <NA> 6621 -#> B08301_008EA B08301_008M B08301_008MA B08301_009E B08301_009EA B08301_009M -#> 1 <NA> 551 <NA> 3380 <NA> 602 -#> 2 <NA> 255 <NA> 654 <NA> 256 -#> 3 <NA> 1062 <NA> 4573 <NA> 689 -#> 4 <NA> 636 <NA> 2137 <NA> 354 -#> 5 <NA> 2554 <NA> 29965 <NA> 1345 -#> 6 <NA> 758 <NA> 2855 <NA> 496 -#> B08301_009MA B08301_010E B08301_010EA B08301_010M B08301_010MA B08301_011E -#> 1 <NA> 6982 <NA> 910 <NA> 6523 -#> 2 <NA> 3805 <NA> 603 <NA> 3415 -#> 3 <NA> 40113 <NA> 2078 <NA> 35607 -#> 4 <NA> 3744 <NA> 551 <NA> 3387 -#> 5 <NA> 662772 <NA> 7190 <NA> 423288 -#> 6 <NA> 63953 <NA> 2586 <NA> 45745 -#> B08301_011EA B08301_011M B08301_011MA B08301_012E B08301_012EA B08301_012M -#> 1 <NA> 928 <NA> 122 <NA> 117 -#> 2 <NA> 577 <NA> 1 <NA> 3 -#> 3 <NA> 1989 <NA> 960 <NA> 238 -#> 4 <NA> 494 <NA> 114 <NA> 97 -#> 5 <NA> 5639 <NA> 140862 <NA> 3435 -#> 6 <NA> 2229 <NA> 4035 <NA> 418 -#> B08301_012MA B08301_013E B08301_013EA B08301_013M B08301_013MA B08301_014E -#> 1 <NA> 77 <NA> 55 <NA> 73 -#> 2 <NA> 15 <NA> 23 <NA> 14 -#> 3 <NA> 471 <NA> 198 <NA> 2692 -#> 4 <NA> 2 <NA> 5 <NA> 59 -#> 5 <NA> 58487 <NA> 2233 <NA> 28260 -#> 6 <NA> 2546 <NA> 416 <NA> 11234 -#> B08301_014EA B08301_014M B08301_014MA B08301_015E B08301_015EA B08301_015M -#> 1 <NA> 95 <NA> 187 <NA> 100 -#> 2 <NA> 15 <NA> 360 <NA> 176 -#> 3 <NA> 455 <NA> 383 <NA> 143 -#> 4 <NA> 51 <NA> 182 <NA> 170 -#> 5 <NA> 1506 <NA> 11875 <NA> 985 -#> 6 <NA> 864 <NA> 393 <NA> 164 -#> B08301_015MA B08301_016E B08301_016EA B08301_016M B08301_016MA B08301_017E -#> 1 <NA> 1253 <NA> 321 <NA> 1878 -#> 2 <NA> 1599 <NA> 368 <NA> 474 -#> 3 <NA> 6508 <NA> 836 <NA> 10036 -#> 4 <NA> 603 <NA> 202 <NA> 1278 -#> 5 <NA> 37588 <NA> 1610 <NA> 46193 -#> 6 <NA> 2955 <NA> 510 <NA> 4587 -#> B08301_017EA B08301_017M B08301_017MA B08301_018E B08301_018EA B08301_018M -#> 1 <NA> 307 <NA> 1805 <NA> 302 -#> 2 <NA> 127 <NA> 2447 <NA> 414 -#> 3 <NA> 824 <NA> 19629 <NA> 1240 -#> 4 <NA> 269 <NA> 2052 <NA> 380 -#> 5 <NA> 1803 <NA> 135240 <NA> 3079 -#> 6 <NA> 503 <NA> 30681 <NA> 1435 -#> B08301_018MA B08301_019E B08301_019EA B08301_019M B08301_019MA B08301_020E -#> 1 <NA> 24058 <NA> 1737 <NA> 16559 -#> 2 <NA> 27039 <NA> 1177 <NA> 13159 -#> 3 <NA> 54751 <NA> 2254 <NA> 40263 -#> 4 <NA> 19571 <NA> 1110 <NA> 11443 -#> 5 <NA> 437430 <NA> 5563 <NA> 220114 -#> 6 <NA> 79574 <NA> 2429 <NA> 24630 -#> B08301_020EA B08301_020M B08301_020MA B08301_021E B08301_021EA B08301_021M -#> 1 <NA> 1341 <NA> 145406 <NA> 4523 -#> 2 <NA> 672 <NA> 28281 <NA> 1635 -#> 3 <NA> 2081 <NA> 462724 <NA> 7442 -#> 4 <NA> 1050 <NA> 87991 <NA> 2781 -#> 5 <NA> 4380 <NA> 2500842 <NA> 15830 -#> 6 <NA> 1187 <NA> 495909 <NA> 6033 -#> B08301_021MA GEO_ID NAME -#> 1 <NA> 0400000US01 Alabama -#> 2 <NA> 0400000US02 Alaska -#> 3 <NA> 0400000US04 Arizona -#> 4 <NA> 0400000US05 Arkansas -#> 5 <NA> 0400000US06 California -#> 6 <NA> 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, @@ -291,16 +179,6 @@

    Examples 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 @@ -310,13 +188,6 @@

    Examples 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 @@ -327,14 +198,7 @@

    Examples 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 -# } +}

    diff --git a/docs/reference/index.html b/docs/reference/index.html index 0353e36..aa68c16 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -111,6 +111,11 @@

    Helpers
    + get_api_key() +
    +
    Retrieve a Census API key stored the .Renivron file
    +
    + fips
    List of state fips codes - 50 states plus DC
    diff --git a/docs/reference/listCensusApis.html b/docs/reference/listCensusApis.html index 5c5d0d9..f229a68 100644 --- a/docs/reference/listCensusApis.html +++ b/docs/reference/listCensusApis.html @@ -88,177 +88,27 @@

    Arguments

    Examples

    -
    # \dontrun{
    +    
    if (FALSE) {
     # 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      <NA>          <NA>
    -#> 2      timeseries/asm/area2017 Timeseries 2018/2021 United States
    -#> 3 timeseries/asm/benchmark2017 Timeseries      <NA>          <NA>
    -#> 4      timeseries/asm/industry Timeseries      <NA> United States
    -#> 5       timeseries/asm/product Timeseries      <NA> United States
    -#> 6         timeseries/asm/state Timeseries      <NA> 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
    -# }
    +}
     
     
    diff --git a/docs/reference/listCensusMetadata.html b/docs/reference/listCensusMetadata.html index 09ae5c3..af51948 100644 --- a/docs/reference/listCensusMetadata.html +++ b/docs/reference/listCensusMetadata.html @@ -91,12 +91,14 @@

    Arguments +

    Type of metadata to return. Options are:

    +

    * "variables" (default) - list of variable names and descriptions + for the dataset. + * "geographies" - available geographies. + * "groups" - available variable groups. Only available + for some datasets. + * "values" - encoded value labels for a given variable. Pair with + "variable_name". Only available for some datasets.

    group
    @@ -119,41 +121,13 @@

    Arguments

    Examples

    -
    # \dontrun{
    +    
    if (FALSE) {
     # 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                               <NA>           int   N/A     0          <NA>
    -#> 5                               <NA>           int   N/A     0          <NA>
    -#> 6                               <NA>        string   N/A     0          <NA>
    -#>            required
    -#> 1              <NA>
    -#> 2              <NA>
    -#> 3              true
    -#> 4              <NA>
    -#> 5              <NA>
    -#> 6 default displayed
     
     # type: variables for a single variable group
     # List the variables that are included in the B17020 group in the
    @@ -164,34 +138,6 @@ 

    Examples 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 @@ -202,27 +148,6 @@

    Examples 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 <NA> int N/A 0 <NA> -#> 5 <NA> int N/A 0 <NA> -#> 6 <NA> int N/A 0 <NA> -#> suggested_weight is_weight values_code values_label -#> 1 <NA> <NA> <NA> <NA> -#> 2 <NA> <NA> <NA> <NA> -#> 3 <NA> <NA> <NA> <NA> -#> 4 PWSSWGT <NA> 46 DOCTORATE DEGREE(EX:PhD,EdD) -#> 5 PWSSWGT <NA> 33 5th Or 6th Grade -#> 6 PWSSWGT <NA> 44 MASTER'S DEGREE(EX:MA,MS,MEng,MEd,MSW) # type: geographies # List the geographies available in the 5-year American Community Survey. @@ -231,20 +156,6 @@

    Examples 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 <NA> -#> 2 <NA> -#> 3 <NA> -#> 4 <NA> -#> 5 state -#> 6 county # type: groups # List the variable groups available in the 5-year American Community Survey. @@ -253,34 +164,6 @@

    Examples 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. @@ -290,14 +173,7 @@

    Examples 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 -# } +}