#Load Ozone Dataset
load("Ozone_Drought_Final.RData")
combinedAir.final<-arrange(combinedAir.final,GEOID,Year)
#Load Population Dataset
m.pop<-read_xlsx("Population/Population County.xlsx")
#Merge two datset
combinedAir.final<-left_join(combinedAir.final,m.pop,by=c("Year","GEOID"="fips"))
#Filter base on category, on July 15, 2012
combine2015<-combinedAir.final%>%
filter(Date..Local.=="2012-07-15")
# Generating Class for favor category
## 1st category is Between 70-1.416 and 70+1.416
## 2nd Category is Betweem 70-3.065 and 70+3.065
## 3rd category is used for all observation outside 1st and 2nd category
combine2015$Class<-ifelse(between(combine2015$Max.Ozone,70-1.416,70),yes = 1,
ifelse(between(combine2015$Max.Ozone,70-3.065,70),yes = 2,
ifelse(between(combine2015$Max.Ozone,70,70+1.416),yes = 3,
ifelse(between(combine2015$Max.Ozone,70,70+3.065),yes = 4,5))))
NOTE : In the result total population on 1st category is 41661.02, and 2nd category is 55595.14 and outsite that category is 751773.8
Here Total population is decimals, it may because Population value is Estimate base on last population cencus.
sumed.pop<-combine2015%>%
group_by(Class)%>%
summarise(Total_pop=sum(value,na.rm = T)*1000,
County=n())
sumed.pop
## # A tibble: 5 × 3
## Class Total_pop County
## <dbl> <dbl> <int>
## 1 1 23654478 27
## 2 2 45392203 34
## 3 3 18006543 10
## 4 4 10202939 14
## 5 5 751773184 1149