Watts-College / cpp-528-fall-2022

https://watts-college.github.io/cpp-528-fall-2022/
1 stars 2 forks source link

Errors with API calls #18

Open Dimetry-Adel opened 1 year ago

Dimetry-Adel commented 1 year ago

Hello @castower I am trying to call population data from US Census Bureau. Although, it worked with Lab04 CPP-529 I have got these two errors:

1

Getting data from the 2016-2020 5-year ACS Downloadingfeature geometry from the Census website. To cache shapefiles for use in future sessions, setoptions(tigris_use_cache = TRUE)`. Warning: '990' is not a valid FIPS code for counties in Ohio

2

Getting data from the 2016-2020 5-year ACS Downloading feature geometry from the Census website. To cache shapefiles for use in future sessions, set options(tigris_use_cache = TRUE). Error: Your API call has errors. The API message returned is error: invalid 'in' argument.

These are my codes: ` census_api_key("key(long)", install = TRUE)

these.msp <- crosswalk$msaname == "OHIO" these.fips <- crosswalk$fipscounty[ these.msp ] these.fips <- na.omit( these.fips )

state.fips <- substr( these.fips, 1, 2 ) county.fips <- substr( these.fips, 3, 5 )

msp.pop1 <- get_acs( geography = "tract", variables = "B01003_001", state = "39", county = county.fips[state.fips=="39"], geometry = TRUE ) %>% select( GEOID, estimate ) %>% rename( POP=estimate )

msp.pop2 <- get_acs( geography = "tract", variables = "B01003_001", state = "48", county = county.fips[state.fips=="48"], geometry = TRUE ) %>% select( GEOID, estimate ) %>% rename( POP=estimate )

msp.pop <- rbind( msp.pop1, msp.pop2 ) `

Could you please advise me? Thanks in advance

castower commented 1 year ago

Hi @Dimetry-Adel I looked at your code again and I realized the issue is not with your county filtration it's your step these.msp <- crosswalk$msaname == "OHIO"

You will need to identify a metro area in Ohio [example Columbus, Cincinnatti, Cleveland, etc.] and then work from there. Then your county filter should work within the get_acs pull

Dimetry-Adel commented 1 year ago

Thank you, It worked.