#Import – J.H.U. Dataset Coronavirus (https://github.com/owid/covid-19-data/tree/master/public/data/)
#install.packages('readr')
library(readr)
d <- read_csv("~/Downloads/WHO-COVID-19-global-data.csv")
## Parsed with column specification:
## cols(
## Date_reported = col_date(format = ""),
## Country_code = col_character(),
## Country = col_character(),
## WHO_region = col_character(),
## New_cases = col_double(),
## Cumulative_cases = col_double(),
## New_deaths = col_double(),
## Cumulative_deaths = col_double()
## )
#Manupilation – Tidyverse
#install.packages('tidyverse')
library(tidyverse)
## ── Attaching packages ────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.2 ✓ dplyr 0.8.5
## ✓ tibble 3.0.1 ✓ stringr 1.4.0
## ✓ tidyr 1.1.0 ✓ forcats 0.4.0
## ✓ purrr 0.3.4
## Warning: package 'ggplot2' was built under R version 3.6.2
## Warning: package 'tibble' was built under R version 3.6.2
## Warning: package 'tidyr' was built under R version 3.6.2
## Warning: package 'purrr' was built under R version 3.6.2
## ── Conflicts ───────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
class(d$Date_reported)
## [1] "Date"
nl = d %>% filter(Country_code=="NL") %>% as.data.frame()
nl <- nl[c(-26, -27),]
#Visualization – ggplot + plotly
library(ggplot2)
library(plotly)
## Warning: package 'plotly' was built under R version 3.6.2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
nl_plot_new_cases = ggplot(nl, aes(x= Date_reported,
y= New_cases)) +
geom_point() + geom_line(color = 'red')
p_nc_nl = ggplotly(nl_plot_new_cases)
p_nc_nl
nl_plot_cum_deaths = ggplot(nl, aes(x= Date_reported,
y= Cumulative_deaths)) +
geom_point() + geom_line(color = "red")
p_cd_nl = ggplotly(nl_plot_cum_deaths)
p_cd_nl