I am looking to create a data frame in R that compiles data based on the county FIPS code. I am pulling FIPS code and county population from df1 and healthcare data from df2 (in which it is also organized by FIPS code but the FIPS codes are not in the same order as df1). I ultimately want something like this, where "x" and "z" are both unique to FIPS code "01001".
FIPS_code | population | healthcare |
---|---|---|
01001 | x | z |
01003 | y | t |
I have done: df = data.frame(df1$FIPS_code, df1$population, df2$healthcare) however this is not ensuring that my "healthcare" column is based on the same FIPS code as "population" column.