Part 4: Census Data
Get Census Data
census_api_key("aa512886c5449a582d837da8d3a07af66a043fe5", install=TRUE, overwrite=T)
[1] "aa512886c5449a582d837da8d3a07af66a043fe5"
censusData = load_variables(2018, "acs5", cache=T)
Download Popultation Data from the Census
populationData = get_acs(geography = "zcta",
variables = 'B01003_001',
geometry = FALSE)
Remove the spurious “ZCTA5” in front of ZIP codes
populationData$mod_zcta = sub("ZCTA5 ", "", populationData$NAME)
Rename the Population Column and Clean Up Your Dataframe
• The population number is given in a column called “estimate.” Rename that column with a more explicit name, such as “population”
populationData =
populationData %>%
rename(population = estimate)
Question 9: Merge the population data with your main dataset
Question 10: Now that you have, for each ZIP code, their counts of ED visits and their populations, create a column that reports the rate of Emergency visits per inhabitant
Students succeed in their courses by connecting and communicating with an expert until they receive help on their questions
Consult our trusted tutors.