R/search_variables.R
load_variables.RdFinding the right variables to use with get_decennial() or get_acs() can be challenging; load_variables() attempts to make this easier for you. Choose a year and a dataset to search for variables; those variables will be loaded from the Census website as an R data frame. It is recommended that RStudio users use the View() function to interactively browse and filter these variables to find the right variables to use.
load_variables(
year,
dataset = c("sf1", "sf2", "sf3", "sf4", "pl", "dhc", "dp", "ddhca", "ddhcb", "sdhc",
"as", "gu", "mp", "vi", "acsse", "dpas", "dpgu", "dpmp", "dpvi", "dhcvi", "dhcgu",
"dhcvi", "dhcas", "acs1", "acs3", "acs5", "acs1/profile", "acs3/profile",
"acs5/profile", "acs1/subject", "acs3/subject", "acs5/subject", "acs1/cprofile",
"acs5/cprofile", "sf2profile", "sf3profile", "sf4profile", "aian", "aianprofile",
"cd110h", "cd110s", "cd110hprofile", "cd110sprofile", "sldh", "slds", "sldhprofile",
"sldsprofile", "cqr",
"cd113", "cd113profile", "cd115", "cd115profile",
"cd116", "plnat", "cd118"),
cache = FALSE,
key = NULL,
clean_labels = FALSE
)The year for which you are requesting variables. Either the year of the decennial Census or the year / endyear of the ACS sample. 5-year ACS data are available from 2009, and 1-year ACS data from 2005, with the exception of 2020.
The dataset name as used on the Census website. See the Details in this documentation for a full list of dataset names.
Deprecated and ignored. Variable metadata is now loaded from the Census API without writing to a local cache.
Your Census API key. Defaults to NULL, which uses your
CENSUS_API_KEY environment variable.
If TRUE, cleans the label column, e.g.
"Estimate!!Total:!!Male:!!Under 5 years" becomes "Total > Male > Under 5 years".
Defaults to FALSE.
A tibble of variables from the requested dataset. For datasets where the
Census API publishes it (ACS detailed tables and the 2020 decennial files), a
universe column gives the universe of each variable's table.
load_variables() returns three columns by default: name, which is the Census ID code to be supplied to the variables parameter in get_decennial() or get_acs(); label, which is a detailed description of the variable; and concept, which provides information about the table that a given variable belongs to. For 5-year ACS detailed tables datasets, a fourth column, geography, tells you the smallest geography at which a given variable is available.
Datasets are named as they are in the Census API; see https://api.census.gov/data.html for a description of each dataset by year.
For the American Community Survey, use "acs1", "acs3", or "acs5" for the Detailed Tables. Add "/profile" for the Data Profile (e.g. "acs5/profile"), "/subject" for the Subject Tables, or "/cprofile" for the Comparison Profile ("acs1/cprofile" and "acs5/cprofile"). "acsse" is the ACS 1-year Supplemental Estimates.
For the decennial Census, use the name of a summary file, as supplied to the sumfile argument of get_decennial(). Run summary_files(year) to see the summary files available for 2000, 2010, or 2020. Common examples are "pl" (Redistricting Data), "dhc" (Demographic and Housing Characteristics, 2020), "dp" (Demographic Profile, 2020), and "sf1" (Summary File 1, 2000 and 2010).
if (FALSE) { # \dontrun{
v15 <- load_variables(2015, "acs5")
View(v15)
} # }