## [1] TRUE
## Parsed with column specification:
## cols(
## .default = col_double(),
## state = col_character(),
## dataQualityGrade = col_character(),
## hospitalized = col_logical(),
## hospitalizedCumulative = col_logical(),
## inIcuCumulative = col_logical(),
## negativeTestsAntibody = col_logical(),
## negativeTestsPeopleAntibody = col_logical(),
## negativeTestsViral = col_logical(),
## onVentilatorCumulative = col_logical(),
## positiveTestsAntibody = col_logical(),
## positiveTestsAntigen = col_logical(),
## positiveTestsPeopleAntibody = col_logical(),
## positiveTestsPeopleAntigen = col_logical(),
## positiveTestsViral = col_logical(),
## recovered = col_logical(),
## totalTestEncountersViral = col_logical(),
## totalTestsAntibody = col_logical(),
## totalTestsAntigen = col_logical(),
## totalTestsPeopleAntibody = col_logical(),
## totalTestsPeopleAntigen = col_logical()
## )
## See spec(...) for full column specifications.
## [1] "date" "state"
## [3] "dataQualityGrade" "death"
## [5] "deathConfirmed" "deathIncrease"
## [7] "deathProbable" "hospitalized"
## [9] "hospitalizedCumulative" "hospitalizedCurrently"
## [11] "hospitalizedIncrease" "inIcuCumulative"
## [13] "inIcuCurrently" "negative"
## [15] "negativeIncrease" "negativeTestsAntibody"
## [17] "negativeTestsPeopleAntibody" "negativeTestsViral"
## [19] "onVentilatorCumulative" "onVentilatorCurrently"
## [21] "pending" "positive"
## [23] "positiveCasesViral" "positiveIncrease"
## [25] "positiveScore" "positiveTestsAntibody"
## [27] "positiveTestsAntigen" "positiveTestsPeopleAntibody"
## [29] "positiveTestsPeopleAntigen" "positiveTestsViral"
## [31] "recovered" "totalTestEncountersViral"
## [33] "totalTestEncountersViralIncrease" "totalTestResults"
## [35] "totalTestResultsIncrease" "totalTestsAntibody"
## [37] "totalTestsAntigen" "totalTestsPeopleAntibody"
## [39] "totalTestsPeopleAntigen" "totalTestsPeopleViral"
## [41] "totalTestsPeopleViralIncrease" "totalTestsViral"
## [43] "totalTestsViralIncrease"
本想用as.Date转化,但是失败了,只好重新生成一列,这种方法仅适用于没有缺失时间的情况。
ILCovid19$Date <- seq.Date(from = as.Date("2020/03/04",format = "%Y/%m/%d"), by = "day", length.out = 194)
tail(ILCovid19$Date)
## [1] "2020-09-08" "2020-09-09" "2020-09-10" "2020-09-11" "2020-09-12"
## [6] "2020-09-13"
## Date[1:194], format: "2020-03-04" "2020-03-05" "2020-03-06" "2020-03-07" "2020-03-08" ...
找到最大值,规定y的上限
## [1] 0.1397892
ggplot(data = ILCovid19)+
geom_line(aes(x=Date,y=Percentage_Positive),color="steelblue")+
geom_hline(aes(yintercept=0.8*max(ILCovid19$Percentage_Positive,na.rm = T)),color="orange")+
scale_y_continuous(breaks = seq(0,0.160,0.01))+
scale_x_date(date_breaks = "1 week",limits = c(ymd(20200304),ymd(20200913)))+
labs(title = "Percentage Positive",y="Percentage")+
theme(plot.title = element_text(size=20,face ="bold",hjust = 0.5),
axis.text.x = element_text(angle = 90,vjust = 0.5))
## Warning: Removed 88 row(s) containing missing values (geom_path).
通过选择行来截取时间
## [1] 0.06886443
ggplot(data = J25_A25)+
geom_line(aes(x=Date,y=Percentage_Positive),color="steelblue")+
scale_y_continuous(breaks = seq(0,0.089,0.005))+
scale_x_date(date_breaks = "1 week")+
labs(title = "July25-August25 Percentage Positive",y="Percentage")+
theme(plot.title = element_text(size=20,face ="bold",hjust = 0.5))
## [1] 3.343727
ggplot(data = ILCovid19)+
geom_line(aes(x=Date,y=Percentage_of_Current_Hospitalizations),color="steelblue")+
scale_y_continuous(breaks = seq(0,3.364,0.2))+
scale_x_date(date_breaks = "1 week")+
labs(title = "Percentage of Current Hospitalizations",y="Percentage")+
theme(plot.title = element_text(size=20,face ="bold",hjust = 0.5),
axis.text.x = element_text(angle = 90,vjust = 0.5))
## Warning: Removed 40 row(s) containing missing values (geom_path).
## [1] 1.035251
ggplot(data = J25_A25)+
geom_line(aes(x=Date,y=Percentage_of_Current_Hospitalizations),color="steelblue")+
scale_y_continuous(breaks = seq(0,1.055,0.02))+
scale_x_date(date_breaks = "1 week")+
labs(title = "July25-August25 Percentage Positive",y="Percentage")+
theme(plot.title = element_text(size=20,face ="bold",hjust = 0.5))
## [1] 0.3168478
ggplot(data = ILCovid19)+
geom_line(aes(x=Date,y=Percentage_of_Current_Hospitalizations_in_ICU),color="steelblue")+
scale_y_continuous(breaks = seq(0,0.337,0.01))+
scale_x_date(date_breaks = "1 week")+
labs(title = "Percentage of Current Hospitalizations in ICU",y="Percentage")+
theme(plot.title = element_text(size=20,face ="bold",hjust = 0.5),
axis.text.x = element_text(angle = 90,vjust = 0.5))
## Warning: Removed 40 row(s) containing missing values (geom_path).
## [1] 0.2448978
ggplot(data = J25_A25 )+
geom_line(aes(x=Date,y=Percentage_of_Current_Hospitalizations_in_ICU),color="steelblue")+
scale_y_continuous(breaks = seq(0,0.265,0.01))+
scale_x_date(date_breaks = "1 week")+
labs(title = "Percentage of Current Hospitalizations in ICU",y="Percentage")+
theme(plot.title = element_text(size=20,face ="bold",hjust = 0.5))