get_variable_names {RcensusPkg}R Documentation

get_variable_names

Description

Get Census Bureau variable acronym names and their label descriptions.

Function produces a data.table of variable acronym names and their descriptions. The function returns 4 columns:

name the name of the parameter
label the Bureau's description of the parameter
required a boolean indicating if the parameter is required
predicateType a string indicating the variable primitive type

Note that a variable with a required character value "true" must be included in your data requests (i.e. RcensusPkg::get_vintage_data()) or the API will return an error.

Usage

get_variable_names(
  dataset = NULL,
  category = NULL,
  vintage = 2020,
  vars = NULL,
  group = NULL,
  filter_group_est = FALSE,
  filter_name_str = NULL,
  filter_label_str = NULL,
  filter_concept_str = NULL,
  ignore_case = TRUE,
  fixed = FALSE
)

Arguments

dataset

An optional string that sets the name of a dataset category of interest.

category

An optional string that sets the category of datasets. The available categories are one of the following:

acs1 American Community Survey 1-Year Data
acs/acsse American Community Survey Supplemental Data
acs5 American Community Survey 5-Year Data
dec Decennial Census
ecnbasic Economy-Wide Key Statistics
timeseries/idb Time Series International Database
abs Annual Business Survey
vintage

An required numeric that sets the year of interest. The default is 2020.

vars

An optional vector of variable names whose descriptions are of interest. This parameter requires that either 'dataset' or 'category' had been defined.

group

An optional string that sets the group name associated with a set of variables. This parameter requires that either 'dataset' or 'category' had been defined. See Rcensus::get_groups() for available group names under a specific dataset and vintage.

filter_group_est

A logical which if TRUE will filter the variable names from 'group' and return only estimate related variable names. The default is FALSE.

filter_name_str

A character string by which to filter the resultant data.table's "name" column.

filter_label_str

A character string by which to filter the resultant data.table's "label" column.

filter_concept_str

A character string by which to filter the resultant data.table's "concept" column.

ignore_case

A logical which if FALSE will not ignore case in filtering the "name", "label", "concept" column.

fixed

A logical which if TRUE, then the above filter strings are used 'as is' in matching.

Details

The function's search for variable names depends on either specifying the parameters 'dataset' name or a dataset 'category'. Entering an available 'vintage' also influences obtaining a full dataframe of variable names and descriptions. To assist in using the function the user should consult the Census Bureau's publicly available datasets descriptions. Also of help is Rcensus::get_dataset_names() for available dataset acronym names and their available years.

Value

A data.table

Examples

# Get available variables that have the phrase "educational attainment"
# in "label" column of the resultant data.table.

library(data.table)
library(httr2)
library(RcensusPkg)

educational_attainment_2019_dt <- RcensusPkg::get_variable_names(
  dataset = "acs/acs1/profile",
  vintage = 2019,
  filter_label_str = "educational attainment"
)


[Package RcensusPkg version 0.1.5 Index]