Add some plots

This commit is contained in:
nlitkowski 2021-05-26 13:17:25 +02:00
parent 59b88d3ad5
commit 016cd2de60

View File

@ -1,14 +1,52 @@
library(dplyr) library(dplyr)
library(highcharter) library(plotly)
library(xts)
cov <- read.csv("proj2/owid-covid-data.csv", header = TRUE) cov <- read.csv("proj2/owid-covid-data.csv", header = TRUE)
df <- data.frame(as.Date(cov$date), cov$location, cov$total_deaths) cov_pl <- cov[cov$location == "Poland",]
cov_xts <- xts(df[-1], order.by = date) plot_ly(
cov_pl,
x = cov_pl$date,
y = cov_pl$new_deaths,
name = "New deaths",
type = "scatter",
mode = "lines+markers"
)
plot_ly(
cov_pl,
x = cov_pl$date,
y = cov_pl$new_deaths_per_million,
name = "New deaths per million",
type = "scatter",
mode = "lines+markers"
) %>%
add_trace(
y = cov_pl$new_cases_per_million,
name = "New cases per million",
type = "scatter",
mode = "lines+markers"
)
cov_pl_vac = cov_pl[as.POSIXct(cov_pl$date) > as.POSIXct('2020-12-12'),]
plot_ly(
cov_pl_vac,
x = cov_pl_vac$date,
y = cov_pl_vac$people_vaccinated,
name = "People vaccinated",
type = "scatter",
mode = "lines",
connectgaps = TRUE
) %>%
add_trace(
y = cov_pl_vac$people_fully_vaccinated,
name = "People fully vaccinated",
type = "scatter",
mode = "lines+markers",
connectgaps = TRUE
)
highchart(type = "stock") %>%
hc_add_series(df[df$location == "Poland",]$total_deaths, type = "line")