library(scales); library(ggplot2); library(readxl)
## Warning: package 'scales' was built under R version 4.0.2
## Warning: package 'ggplot2' was built under R version 4.0.2
# https://covidlive.com.au/report/daily-positive-test-rate/nsw
df = read_excel("~/Dropbox/Bao chi/Khoa hoc & Y te/Du bao dich NSW/Number tests and postives.xlsx")
df$date = as.Date(df$Date)
df
## # A tibble: 86 x 5
## Date Pos Tests Rate date
## <dttm> <dbl> <dbl> <dbl> <date>
## 1 2021-08-25 00:00:00 919 149252 0.00616 2021-08-25
## 2 2021-08-24 00:00:00 755 138472 0.00545 2021-08-24
## 3 2021-08-23 00:00:00 818 311083 0.00263 2021-08-23
## 4 2021-08-22 00:00:00 830 206193 0.00403 2021-08-22
## 5 2021-08-21 00:00:00 832 124610 0.00668 2021-08-21
## 6 2021-08-20 00:00:00 646 127590 0.00506 2021-08-20
## 7 2021-08-19 00:00:00 684 119310 0.00573 2021-08-19
## 8 2021-08-18 00:00:00 634 102749 0.00617 2021-08-18
## 9 2021-08-17 00:00:00 454 151767 0.00299 2021-08-17
## 10 2021-08-16 00:00:00 480 156495 0.00307 2021-08-16
## # … with 76 more rows
Data visualization
ggplot(data=df, aes(x=date, y=Pos)) + geom_point(col="blue") + labs(x="Date", y="Number of cases") + scale_x_date(date_breaks = "1 week") + theme(axis.text.x = element_text(angle = 45, hjust = 1))
ggplot(data=df, aes(x=Tests, y=Pos)) + geom_point() + labs(x="Number of tests", y="Number of cases") + scale_x_continuous(labels = comma) + scale_y_continuous(labels = comma)