Calculates the Population of Counties Given a Vector of Counties and States
Calc_Counties_Pop.Rd
This is a helper function for the DSPGrocery::Auto_Rural_Pop function which calculates the total population of counties within states given a data frame containing a vector of county names and state names.
Arguments
- states_unique
this is a vector of unique state FIPS codes inherited from the df_buffer_loc parameter in DSPGrocery::Auto_Rural_Pop.
- df_buffer_loc
this is a data frame inherited from DSPGrocery::Auto_Rural_Pop.
Value
the function returns a data frame called all_counties_pops
containing
county, county population, and sf geographies. The data frame is returned
with an attribute called "all_population" which is the sum of county populations.
Details
The call uses data pulled from the United States Census Bureau with a call to the tidycensus API, tidycensus::get_decennial.