Skip to content

Pass year parameter through to tidycensus::load_variables() #70

@wcurrangroome

Description

@wcurrangroome

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.Rcollect_raw_variables() line: tidycensus::load_variables(year = 2022, dataset = "acs5")
  • R/generate_codebook.Rgenerate_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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions