Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jaytimm
Created January 7, 2019 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaytimm/717b0ac226d9a0431afc4e49a2175f50 to your computer and use it in GitHub Desktop.
Save jaytimm/717b0ac226d9a0431afc4e49a2175f50 to your computer and use it in GitHub Desktop.
get_historic_acs <- function (variables,
geography,
state = NULL,
year,
summary_var = NULL,
var_names) {
label <- var_names; variable <- variables
y <- list()
for (i in 1:length(year)) {
y[[i]] <- lapply(1:length(geography), function (x) {
tidycensus::get_acs (geography = geography[[x]],
variables = variables,
summary_var = summary_var,
output = "tidy", survey = 'acs1',
state = state[[x]],
year = year[i])}) %>%
bind_rows() %>%
mutate(year = year[i]) }
y %>%
bind_rows() %>%
left_join(data.frame(label, variable), stringsAsFactors = FALSE)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment