Datos descargados de la OMS: https://covid19.who.int/
COVID19 <- read.csv("~/MAIN/VisualizacionDatos/covid-19/COVID19_20210529.csv")
View(COVID19)
str(COVID19)
## 'data.frame': 121581 obs. of 8 variables:
## $ ï..Date_reported : chr "2020-01-03" "2020-01-04" "2020-01-05" "2020-01-06" ...
## $ Country_code : chr "AF" "AF" "AF" "AF" ...
## $ Country : chr "Afghanistan" "Afghanistan" "Afghanistan" "Afghanistan" ...
## $ WHO_region : chr "EMRO" "EMRO" "EMRO" "EMRO" ...
## $ New_cases : int 0 0 0 0 0 0 0 0 0 0 ...
## $ Cumulative_cases : int 0 0 0 0 0 0 0 0 0 0 ...
## $ New_deaths : int 0 0 0 0 0 0 0 0 0 0 ...
## $ Cumulative_deaths: int 0 0 0 0 0 0 0 0 0 0 ...
names(COVID19)[1] <- "Date"
COVID19$Date <- as.Date(COVID19$Date)
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.0.5
plotBase <- ggplot(COVID19, aes(Date, New_cases))
plotBase <- plotBase + geom_bar(stat="identity")
# accommodate labels
plotBase <- plotBase + labs(title = "Nuevos casos diarios",
x= "Date", y= "Nuevos casos")
plotBase <- plotBase + theme(axis.text.x = element_text(angle = 90, hjust = 1))
# plot chart
plotBase
plotBase <- ggplot(COVID19, aes(Date, New_cases, fill = WHO_region))
plotBase <- plotBase + geom_bar(stat="identity")
# accommodate labels
plotBase <- plotBase + labs(title = "Nuevos casos diarios por region",
x= "Date", y= "Nuevos casos")
plotBase <- plotBase + theme(axis.text.x = element_text(angle = 90, hjust = 1))
# plot chart
plotBase
plotBase <- ggplot(COVID19, aes(Date, New_cases, fill = WHO_region))
plotBase <- plotBase + geom_bar(stat="identity")
# accommodate labels
plotBase <- plotBase + labs(title = "Nuevos casos diarios por region",
x= "Date", y= "Nuevos casos")
plotBase <- plotBase + theme(axis.text.x = element_text(angle = 90, hjust = 1))
# facets
plotBase <- plotBase + facet_grid(WHO_region ~ .)
# plot chart
plotBase
colombia <- subset(COVID19, COVID19$Country_code == 'CO')
plotBase <- ggplot(colombia, aes(Date, New_cases, group = Country_code))
plotBase <- plotBase + geom_line()
# accommodate labels
plotBase <- plotBase + labs(title = "Nuevos casos diarios en Colombia",
x= "Date", y= "Nuevos casos")
plotBase <- plotBase + theme(axis.text.x = element_text(angle = 90, hjust = 1))
plotBase <- plotBase + scale_x_date(date_breaks = "1 month")
# plot chart
plotBase