Created
January 7, 2019 19:15
-
-
Save jaytimm/717b0ac226d9a0431afc4e49a2175f50 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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