Hi everyone,
I'm currently working on code for TidyCensus. I'm trying to pull data by block group to find statistics for target areas made of block groups. Here is a snippet of what I currently have.
report_year = 2020
report_geography = "block group"
report_geoid = 482015523031
report_state = "TX"
report_survey = "acs5"
export_name = "Blockgroup_2020_Snapshot.csv"
acs_lan_1 <- get_acs(
geography = report_geography,
state = report_state,
year = report_year,
survey = report_survey,
summary_var = "C16001_001",
variables = c(
"C16001_002",
"C16001_003",
"C16001_012",
"C16001_021",
"C16001_027",
"C16001_033",
"C16001_018"))%>%
filter(GEOID == report_geoid)
acs_lan_1b <- acs_lan_1 %>%
mutate(value = ((estimate/1))) %>%
select(variable, estimate, value, summary_est) %>%
mutate(percent = (value/summary_est)) %>%
select(variable, value, percent)
acs_lan_1b[acs_lan_1b == "C16001_002"] <- "English Only"
acs_lan_1b[acs_lan_1b == "C16001_003"] <- "Spanish"
acs_lan_1b[acs_lan_1b == "C16001_012"] <- "Slavic Languages"
acs_lan_1b[acs_lan_1b == "C16001_021"] <- "Chinese"
acs_lan_1b[acs_lan_1b == "C16001_027"] <- "Tagalog"
acs_lan_1b[acs_lan_1b == "C16001_033"] <- "Arabic"
acs_lan_1b[acs_lan_1b == "C16001_018"] <- "Korean"
I am very new to R so I'm sure this code isn't as efficient as it could be but I was curious if there is a way to add multiple variables to my report_geoid value and include that in the code as my filter so I wont have to rerun the code for each block group in the target areas (some target areas include 20+ block groups).
The code I wrote is very long so I would prefer to not to do a set of code for each block group but might not have a choice.
Thanks for any help!