Add new plot
This commit is contained in:
parent
c4b1aa0008
commit
6eb390fb21
@ -1,10 +1,13 @@
|
|||||||
library(dplyr)
|
library(dplyr)
|
||||||
library(plotly)
|
library(plotly)
|
||||||
|
library(mgcv)
|
||||||
|
|
||||||
cov <- read.csv("proj2/owid-covid-data.csv", header = TRUE)
|
cov <- read.csv("proj2/owid-covid-data.csv", header = TRUE)
|
||||||
|
|
||||||
cov_pl <- cov[cov$location == "Poland",]
|
cov_pl <- cov[cov$location == "Poland",]
|
||||||
|
|
||||||
|
# Poland - new deaths by date ---------------------------------------------
|
||||||
|
|
||||||
plot_ly(
|
plot_ly(
|
||||||
cov_pl,
|
cov_pl,
|
||||||
x = cov_pl$date,
|
x = cov_pl$date,
|
||||||
@ -14,6 +17,8 @@ plot_ly(
|
|||||||
mode = "lines+markers"
|
mode = "lines+markers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Poland - new deaths vs new cases per million ----------------------------
|
||||||
|
|
||||||
plot_ly(
|
plot_ly(
|
||||||
cov_pl,
|
cov_pl,
|
||||||
x = cov_pl$date,
|
x = cov_pl$date,
|
||||||
@ -29,6 +34,8 @@ plot_ly(
|
|||||||
mode = "lines+markers"
|
mode = "lines+markers"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Poland - vaccines by date -----------------------------------------------
|
||||||
|
|
||||||
cov_pl_vac = cov_pl[as.POSIXct(cov_pl$date) > as.POSIXct('2020-12-12'),]
|
cov_pl_vac = cov_pl[as.POSIXct(cov_pl$date) > as.POSIXct('2020-12-12'),]
|
||||||
|
|
||||||
plot_ly(
|
plot_ly(
|
||||||
@ -48,5 +55,29 @@ plot_ly(
|
|||||||
connectgaps = TRUE
|
connectgaps = TRUE
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# World - new deaths vs new vaccines ---------------------------------------
|
||||||
|
|
||||||
|
cov_vac <- cov[as.POSIXct(cov$date) > as.POSIXct('2020-12-12'),]
|
||||||
|
cov_vac[["new_vaccinations"]][is.na(cov_vac[["new_vaccinations"]])] <- 0
|
||||||
|
cov_vac[["new_deaths"]][is.na(cov_vac[["new_deaths"]])] <- 0
|
||||||
|
df <- data.frame(
|
||||||
|
date=cov_vac$date,
|
||||||
|
new_deaths=cov_vac$new_deaths,
|
||||||
|
new_vaccinations=cov_vac$new_vaccinations
|
||||||
|
)
|
||||||
|
df <- df %>%
|
||||||
|
group_by(date)
|
||||||
|
|
||||||
|
plot_ly(
|
||||||
|
df,
|
||||||
|
x = df$date,
|
||||||
|
y = df$new_deaths,
|
||||||
|
name = "New deaths",
|
||||||
|
type = "scatter",
|
||||||
|
mode = "lines"
|
||||||
|
) %>%
|
||||||
|
add_lines(
|
||||||
|
y = df$new_vaccinations,
|
||||||
|
name = "New vaccines"
|
||||||
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user