Summary
collect_raw_variables() and generate_codebook() both hardcode year = 2022 in their calls to tidycensus::load_variables(). This means the census codebook used for variable name resolution always reflects 2022, regardless of the years argument passed to compile_acs_data().
Locations
R/table_registry.R — collect_raw_variables() line: tidycensus::load_variables(year = 2022, dataset = "acs5")
R/generate_codebook.R — generate_codebook() line: tidycensus::load_variables(year = 2022, dataset = "acs5")
Considerations
- Variable availability can differ across ACS vintages (e.g., new tables added, old tables retired)
- For multi-year queries (
years = c(2019, 2022)), it's unclear which year's codebook should be used — possibly the most recent
- This is a low-risk issue in practice since most supported tables have been stable across recent ACS vintages
- Fixing this requires threading the year parameter from
compile_acs_data() down to both functions
Suggested approach
Pass years[1] (or max(years)) from compile_acs_data() through to both collect_raw_variables() and generate_codebook(). collect_raw_variables() already accepts a year parameter but ignores it internally.
Summary
collect_raw_variables()andgenerate_codebook()both hardcodeyear = 2022in their calls totidycensus::load_variables(). This means the census codebook used for variable name resolution always reflects 2022, regardless of theyearsargument passed tocompile_acs_data().Locations
R/table_registry.R—collect_raw_variables()line:tidycensus::load_variables(year = 2022, dataset = "acs5")R/generate_codebook.R—generate_codebook()line:tidycensus::load_variables(year = 2022, dataset = "acs5")Considerations
years = c(2019, 2022)), it's unclear which year's codebook should be used — possibly the most recentcompile_acs_data()down to both functionsSuggested approach
Pass
years[1](ormax(years)) fromcompile_acs_data()through to bothcollect_raw_variables()andgenerate_codebook().collect_raw_variables()already accepts ayearparameter but ignores it internally.