Skip to contents

acs_table_variables() helps to make a vector of variable ID values based on a table ID string. The returned variable IDs use the format returned by tidycensus::get_acs(), e.g. "table_id_line_number" where the line_number is a width 3 string prefixed by "0". If variables is NULL, the function calls get_acs_metadata() with metadata = "column" and returns all available variables for the table for the supplied year and survey. Note that the sep and width parameters should not be changed if you are working with data from the {tidycensus} package.

Usage

acs_table_variables(
  table = NULL,
  variables = NULL,
  data = NULL,
  survey = "acs5",
  year = 2021,
  sep = "_",
  width = 3,
  error_call = caller_env()
)

Arguments

table

An ACS table ID string.

variables

A numeric vector corresponding to the line number of the variables.

data

If data is provided and table is NULL, table is set based on the unique values in the "table_id" column of data. If data contains more than one table_id value, the function will error

survey

Survey, "acs5", "acs3", or "acs1".

year

Sample year (between 2006 and 2021).

sep

A separator character between the table ID string and variable ID values.

width

Variable ID suffix width.

error_call

The execution environment of a currently running function, e.g. caller_env(). The function will be mentioned in error messages as the source of the error. See the call argument of abort() for more information.

Value

A character vector of variable ID values for a single table.