listCensusMetadata: Get metadata about a specified API endpoint

View source: R/metadata_functions.R

listCensusMetadataR Documentation

Get metadata about a specified API endpoint

Description

Get information about a Census Bureau API dataset, including its available variables, geographies, variable groups, and value labels

Usage

listCensusMetadata(
  name,
  vintage = NULL,
  type = "variables",
  group = NULL,
  variable_name = NULL,
  include_values = FALSE
)

Arguments

name

API programmatic name - e.g. acs/acs5. Use listCensusApis() to see valid dataset names.

vintage

Vintage (year) of dataset. Not required for timeseries APIs.

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.

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.

variable_name

A name of a specific variable used to return value labels for that variable. Value labels are not used for all APIs.

include_values

Use with type = "variables". Include value metadata for all variables in a dataset if value metadata exists. Default is "FALSE".

Value

A data frame with metadata about the specified API endpoint.

See Also

Other metadata: listCensusApis(), makeVarlist()

Examples


# type: variables # List the variables available in the Small Area
# Health Insurance Estimates.
variables <- listCensusMetadata(
  name = "timeseries/healthins/sahie", type = "variables")
head(variables)

# 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)

# 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)

# type: geographies
# List the geographies available in the 5-year American Community Survey.
geographies <- listCensusMetadata(
  name = "acs/acs5",
  vintage = 2022,
  type = "geographies")
head(geographies)

# 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)

# 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)


hrecht/censusapi documentation built on April 8, 2024, 9:21 a.m.