Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save elipousson/b216a03f830df9a9b7f192f77b5b0de5 to your computer and use it in GitHub Desktop.

Select an option

Save elipousson/b216a03f830df9a9b7f192f77b5b0de5 to your computer and use it in GitHub Desktop.
table <- tidycensus::get_decennial(
geography = "block",
state = "MD",
county = "Baltimore city",
year = 2020,
table = "H1"
)
label_census <- function(data,
year = 2020,
dataset = "pl",
survey = NULL,
cache = TRUE,
variable_col = "variable") {
vars <- tidycensus::load_variables(year, survey %||% dataset, cache)
vars <- dplyr::rename(vars, "{variable_col}" := name)
dplyr::left_join(
data,
vars,
by = dplyr::join_by({{ variable_col }})
)
}
label_census(table)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment