-1

I am working with a dataset in R(county_data) and I have on a consumption column for every county in every state of the US. I tried to merge it with a dataset with fips code(I believe it comes with tidycensus package) but I noticed that there are multiple fips code for a single county. Why is that?

I was expecting to see just a single FIPS code so I could merge it with my county data and plot it. I tried merging the county_data to the fips_data, and not the same consumption has been duplicated for the multiple versions of same county that are present in the fips dataset.

An Ad
  • 3
  • 1
  • 1
    Welcome to SO! You maximise your chance of getting a useful answer if you provide a minimal reproducible example. [This post](https://stackoverflow.com/help/minimal-reproducible-example) may help. At the moment, we can do nothing more than speculate... – Limey May 12 '23 at 14:08
  • You may want to reach out to the devs instead... A county is not supposed to have more than one from what I'm seeing. – stefan_aus_hannover May 12 '23 at 14:43
  • https://github.com/walkerke/tidycensus/issues – stefan_aus_hannover May 12 '23 at 14:43

1 Answers1

0

If there is a substantive change to a county (like a name change, or a notable boundary change) Census will change the FIPS code. tidycensus includes all version of that over time so that users can request counties by name across the different years.

I don't typically recommend using fips_codes for that purpose, it's an internal dataset that we use to translate county names to FIPS codes for users.

If you want counties with FIPS codes for a given year, fetch that data with the tigris package (e.g. counties(year = 2022)) and pull out the FIPS code (typically called GEOID) and the name.

It's tough to say without your specific example, but I would also be very careful if you are merging on county names which it sounds like you are doing given different spellings (e.g. Saint Louis vs. St. Louis).

kwalkertcu
  • 1,011
  • 6
  • 8