#############
# Coronavirus
#############

jhu_url <- paste("https://raw.githubusercontent.com/CSSEGISandData/", 
                 "COVID-19/master/csse_covid_19_data/", "csse_covid_19_time_series/", 
                 "time_series_covid19_confirmed_global.csv", sep = "")


# library(readr)
confirmed_long_jhu <- read.csv(jhu_url) 
class(confirmed_long_jhu)
str(confirmed_long_jhu)

head(confirmed_long_jhu[,1:2])
tail(confirmed_long_jhu[,1:2])
confirmed_long_jhu[,1]
which(confirmed_long_jhu[,2] == "Spain") 
confirmed_long_jhu[242,]

dates <- seq(as.Date("2020/1/22"), as.Date("2022/10/15"), "days")
dates <- seq(as.Date("22-1-2020", format="%d-%m-%Y"), as.Date("15-10-2022", format="%d-%m-%Y"), "days")

casos <- confirmed_long_jhu[242,-c(1:4)]

barplot(as.numeric(casos), names.arg = dates, 
        main = "Casos de COVID-19 en España (15/10/2022)",
        sub="Fuente: John Hopkins University")

library(coronavirus)
data(coronavirus)
