Skip to contents

These simple functions allow validating ACS survey options, getting comparable years for time series analysis, and creating standard labels.

Usage

acs_survey_match(survey = "acs5", error_call = caller_env())

acs_survey_sample(survey = "acs5")

acs_survey_ts(survey = "acs5", year = 2021, call = caller_env())

acs_survey_label(
  survey = "acs5",
  year = 2021,
  pattern = "{year_start}-{year} ACS {sample}-year Estimates",
  prefix = ""
)

acs_survey_label_table(
  survey = "acs5",
  year = 2021,
  prefix = "",
  table = NULL,
  table_label = "Table",
  sep = ", ",
  and = " and ",
  before = "",
  after = before,
  end = ".",
  oxford_comma = TRUE
)

Arguments

survey

ACS survey, "acs5", "acs3", or "acs1".

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.

year

Based on the year and survey, acs_survey_ts() returns a vector of years for non-overlapping ACS samples to allow comparison.

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.

pattern

Pattern passed to glue::glue(). Allows use of the year_start variable which is the earliest year for a survey sample specified by the survey parameter.

prefix

Text to insert before ACS survey label.

table

One or more table IDs to include in label or source note.

table_label

Label to use when referring to table or tables. A "s" is appended to the end of the table_label if tables is more than length 1.

sep

Separator to be inserted between words.

and

Character string to be prepended to the last word.

before, after

A character string to be added before/after each word.

end

A character string appended to the end of the full label. Defaults to ".".

oxford_comma

Whether to insert the separator between the last two elements in the list.

Examples

acs_survey_match("acs1")
#> [1] "acs1"

acs_survey_sample("acs3")
#> [1] "3"

acs_survey_ts("acs5", 2020)
#>  Learn more about comparing 2020 American Community Survey Data:
#>   <https://www.census.gov/programs-surveys/acs/guidance/comparing-acs-data/2020.html>
#> [1] 2020 2015 2010

acs_survey_label()
#> 2017-2021 ACS 5-year Estimates

acs_survey_label_table(table = c("B19013", "B01003"))
#> 2017-2021 ACS 5-year Estimates, Tables B19013 and B01003.