Dataset
load("Ozone Data with Region.RData")
pop <- read_excel("Population/Population County.xlsx")
pop12<-pop%>%filter(Year==2012)
Scenario A
## A1
A<-df4%>%
filter(Year==2012,between(Max.Ozone,75,75+0.905))
unique(A$GEOID)%>%length()
## [1] 349
unique(A$Date..Local.)%>%length()
## [1] 160
A<-left_join(A,pop12,by=c("GEOID"="fips"))
A.pop<-A%>%
distinct(GEOID,MonitorID,.keep_all = T)%>%
group_by(GEOID,MonitorID,Max.Ozone)%>%
summarise(pop=value) # ALL OZONE LEVEL IS 75, So i think it have same kind of drought
## `summarise()` has grouped output by 'GEOID', 'MonitorID'. You can override
## using the `.groups` argument.
A.pop<-A.pop%>%
group_by(GEOID)%>%
summarise(Pop=mean(pop))%>%
mutate(Sumpop=sum(Pop,na.rm = T)*1000)
A.pop%>%head(3)
## # A tibble: 3 × 3
## GEOID Pop Sumpop
## <chr> <dbl> <dbl>
## 1 01049 70.9 132814089
## 2 01073 658. 132814089
## 3 01089 343. 132814089
### A2
A2<-df4%>%
filter(Year==2012,between(Max.Ozone,70,70+0.905))
unique(A2$GEOID)%>%length()
## [1] 517
unique(A2$Date..Local.)%>%length()
## [1] 196
A2<-left_join(A2,pop12,by=c("GEOID"="fips"))
A2.pop<-A2%>%
distinct(GEOID,MonitorID,.keep_all = T)%>%
group_by(GEOID,MonitorID,Max.Ozone)%>%
summarise(pop=value) # ALL OZONE LEVEL IS 70
## `summarise()` has grouped output by 'GEOID', 'MonitorID'. You can override
## using the `.groups` argument.
A2.pop<-A2.pop%>%
group_by(GEOID)%>%
summarise(Pop=mean(pop))%>%
mutate(Sumpop=sum(Pop,na.rm = T)*1000)
A2.pop%>%head(3)
## # A tibble: 3 × 3
## GEOID Pop Sumpop
## <chr> <dbl> <dbl>
## 1 01033 54.6 178745925
## 2 01051 80.2 178745925
## 3 01073 658. 178745925
###A3
A3<-df4%>%
filter(Year==2012,between(Max.Ozone,51,51+0.905))
unique(A3$GEOID)%>%length()
## [1] 772
unique(A3$Date..Local.)%>%length()
## [1] 320
A3<-left_join(A3,pop12,by=c("GEOID"="fips"))
A3.pop<-A3%>%
distinct(GEOID,MonitorID,.keep_all = T)%>%
group_by(GEOID,MonitorID,Max.Ozone)%>%
summarise(pop=value) # ALL OZONE LEVEL IS 51
## `summarise()` has grouped output by 'GEOID', 'MonitorID'. You can override
## using the `.groups` argument.
A3.pop<-A3.pop%>%
group_by(GEOID)%>%
summarise(Pop=mean(pop))%>%
mutate(Sumpop=sum(Pop,na.rm = T)*1000)
A3.pop%>%head(3)
## # A tibble: 3 × 3
## GEOID Pop Sumpop
## <chr> <dbl> <dbl>
## 1 01003 190. 225735053
## 2 01033 54.6 225735053
## 3 01049 70.9 225735053
Scenario B
## Scenario B
B<-df4%>%
filter(Year==2012,between(Max.Ozone,75,75+0.905)|between(Max.Ozone,75,75+1.693))
unique(B$GEOID)%>%length()
## [1] 442
unique(B$Date..Local.)%>%length()
## [1] 172
B<-left_join(B,pop12,by=c("GEOID"="fips"))
B.pop<-B%>%
distinct(GEOID,MonitorID,.keep_all = T)%>%
group_by(GEOID,MonitorID,Max.Ozone)%>%
summarise(pop=value) # ALL OZONE LEVEL IS 75, So i think it have same kind of drought
## `summarise()` has grouped output by 'GEOID', 'MonitorID'. You can override
## using the `.groups` argument.
B.pop<-B.pop%>%
group_by(GEOID)%>%
summarise(Pop=mean(pop))%>%
mutate(Sumpop=sum(Pop,na.rm = T)*1000)
B.pop%>%head(3)
## # A tibble: 3 × 3
## GEOID Pop Sumpop
## <chr> <dbl> <dbl>
## 1 01049 70.9 158680441
## 2 01073 658. 158680441
## 3 01089 343. 158680441
### B2
B2<-df4%>%
filter(Year==2012,between(Max.Ozone,70,70+0.905)|between(Max.Ozone,70,70+1.693))
unique(B2$GEOID)%>%length()
## [1] 606
unique(B2$Date..Local.)%>%length()
## [1] 204
B2<-left_join(B2,pop12,by=c("GEOID"="fips"))
B2.pop<-B2%>%
distinct(GEOID,MonitorID,.keep_all = T)%>%
group_by(GEOID,MonitorID,Max.Ozone)%>%
summarise(pop=value)
## `summarise()` has grouped output by 'GEOID', 'MonitorID'. You can override
## using the `.groups` argument.
B2.pop<-B2.pop%>%
group_by(GEOID)%>%
summarise(Pop=mean(pop))%>%
mutate(Sumpop=sum(Pop,na.rm = T)*1000)
B2.pop%>%head(3)
## # A tibble: 3 × 3
## GEOID Pop Sumpop
## <chr> <dbl> <dbl>
## 1 01033 54.6 198796234
## 2 01049 70.9 198796234
## 3 01051 80.2 198796234
###B3
B3<-df4%>%
filter(Year==2012,between(Max.Ozone,51,51+0.905)|between(Max.Ozone,51,51+1.693))
unique(B3$GEOID)%>%length()
## [1] 775
unique(B3$Date..Local.)%>%length()
## [1] 337
B3<-left_join(B3,pop12,by=c("GEOID"="fips"))
B3.pop<-B3%>%
distinct(GEOID,MonitorID,.keep_all = T)%>%
group_by(GEOID,MonitorID,Max.Ozone)%>%
summarise(pop=value)
## `summarise()` has grouped output by 'GEOID', 'MonitorID'. You can override
## using the `.groups` argument.
B3.pop<-B3.pop%>%
group_by(GEOID)%>%
summarise(Pop=mean(pop))%>%
mutate(Sumpop=sum(Pop,na.rm = T)*1000)
B3.pop%>%head(3)
## # A tibble: 3 × 3
## GEOID Pop Sumpop
## <chr> <dbl> <dbl>
## 1 01003 190. 225894339
## 2 01033 54.6 225894339
## 3 01049 70.9 225894339
Scenario C
### Scenario C
C<-df4%>%
filter(Year==2012,between(Max.Ozone,75,75+2.598)|between(Max.Ozone,75,75+1.693))
unique(C$GEOID)%>%length()
## [1] 488
unique(C$Date..Local.)%>%length()
## [1] 179
C<-left_join(C,pop12,by=c("GEOID"="fips"))
C.pop<-C%>%
distinct(GEOID,MonitorID,.keep_all = T)%>%
group_by(GEOID,MonitorID,Max.Ozone)%>%
summarise(pop=value) # ALL OZONE LEVEL IS 75, So i think it have same kind of drought
## `summarise()` has grouped output by 'GEOID', 'MonitorID'. You can override
## using the `.groups` argument.
C.pop<-C.pop%>%
group_by(GEOID)%>%
summarise(Pop=mean(pop))%>%
mutate(Sumpop=sum(Pop,na.rm = T)*1000)
C.pop%>%head(3)
## # A tibble: 3 × 3
## GEOID Pop Sumpop
## <chr> <dbl> <dbl>
## 1 01049 70.9 172255515
## 2 01073 658. 172255515
## 3 01089 343. 172255515
### C2
C2<-df4%>%
filter(Year==2012,between(Max.Ozone,70,70+2.598)|between(Max.Ozone,70,70+1.693))
unique(C2$GEOID)%>%length()
## [1] 637
unique(C2$Date..Local.)%>%length()
## [1] 205
C2<-left_join(C2,pop12,by=c("GEOID"="fips"))
C2.pop<-C2%>%
distinct(GEOID,MonitorID,.keep_all = T)%>%
group_by(GEOID,MonitorID,Max.Ozone)%>%
summarise(pop=value)
## `summarise()` has grouped output by 'GEOID', 'MonitorID'. You can override
## using the `.groups` argument.
C2.pop<-C2.pop%>%
group_by(GEOID)%>%
summarise(Pop=mean(pop))%>%
mutate(Sumpop=sum(Pop,na.rm = T)*1000)
C2.pop%>%head(3)
## # A tibble: 3 × 3
## GEOID Pop Sumpop
## <chr> <dbl> <dbl>
## 1 01003 190. 202848364
## 2 01033 54.6 202848364
## 3 01049 70.9 202848364
###C3
C3<-df4%>%
filter(Year==2012,between(Max.Ozone,51,51+2.598)|between(Max.Ozone,51,51+1.693))
unique(C3$GEOID)%>%length()
## [1] 776
unique(C3$Date..Local.)%>%length()
## [1] 340
C3<-left_join(C3,pop12,by=c("GEOID"="fips"))
C3.pop<-C3%>%
distinct(GEOID,MonitorID,.keep_all = T)%>%
group_by(GEOID,MonitorID,Max.Ozone)%>%
summarise(pop=value)
## `summarise()` has grouped output by 'GEOID', 'MonitorID'. You can override
## using the `.groups` argument.
C3.pop<-C3.pop%>%
group_by(GEOID)%>%
summarise(Pop=mean(pop))%>%
mutate(Sumpop=sum(Pop,na.rm = T)*1000)
C3.pop %>% head(3)
## # A tibble: 3 × 3
## GEOID Pop Sumpop
## <chr> <dbl> <dbl>
## 1 01003 190. 226634039
## 2 01033 54.6 226634039
## 3 01049 70.9 226634039