VISUALIZACIÓN DESCRIPTIVA DEL COVID 19 -12 JUNIO, 2020

Datos descargados de la Organización Mundial de la Salud:

https://covid19.who.int/WHO-COVID-19-global-data.csv

##CASOS DIARIOS - MUERTE

# Archivo de origen  

who <- read.csv("C:/Users/Julian/Desktop/ejercicios univalle/cov19/who.csv")

str(who)
## 'data.frame':    124899 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 ...
library(ggplot2)

#cambio el nombre que estaba muy largo y con caracteres especiales "Ï...data..." por fecha
names(who)[1]="fecha"

#voy a graficar, manteniendo la gramática gráfica de ggplot

gbarras<-ggplot(who, aes(fecha, New_deaths))
gbarras<-gbarras+geom_bar(stat='identity')
gbarras<-gbarras+labs(title="NUEVAS MUERTES POR COVID A NIVEL MUNDIAL", x="Dia", y="Nuevas Muertes")
gbarras<-gbarras+theme(axis.text.x=element_text(angle=90, size=6, hjust=1))
gbarras

#En el eje x, de esta manera, se recomienda trabajar un volumen de datos que se pueda leer. Para este caso, las fechas diarias de más de 1 año, no son posible visualizarlas correctamente. 

CASO DE SIMPLIFICACIÓN DE FECHAS (CAMBIO DE DIARIO A SEMANAL)

#cambio la variable a fecha a tipo de dato Fecha

who$fecha<-as.Date(who$fecha)

graf1<-ggplot(who, aes(x=fecha, y=New_cases))
graf1<-graf1 + geom_bar(stat='identity')
graf1<-graf1 + labs(title = "NUEVOS CASOS GLOBALES DE SARS COV2 REPORTADOS", x="SEMANAS", y="CASOS NUEVOS")
graf1<-graf1 + theme (axis.text.x=element_text(angle=90, size=6, hjust=1))
graf1<-graf1 + scale_x_date(date_breaks = "1 week")
graf1

CASOS MUERTES DIARIAS POR REGIÓN

gbarras<-ggplot(who, aes(fecha, New_deaths, fill=WHO_region))
gbarras<-gbarras+geom_bar(stat='identity')
gbarras<-gbarras+labs(title="NUEVAS MUERTES POR COVID A NIVEL MUNDIAL", x="fecha", y="Nuevas Muertes por región")
gbarras<-gbarras+theme(axis.text.x=element_text(angle=90, size=6, hjust=1))
gbarras<-gbarras + scale_x_date(date_breaks = "1 month")
gbarras

#African Region=AFRO
#Eastern Mediterranean Region=EMRO
#European Region=EURO
#Region of the Americas=AMRO
#South-East Asia Region=SEARO
#Western Pacific Region=WPRO

CASOS MUERTES DIARIAS POR REGIÓN (separados)

gbarras<-gbarras +facet_grid(WHO_region~.)
gbarras

#African Region=AFRO
#Eastern Mediterranean Region=EMRO
#European Region=EURO
#Region of the Americas=AMRO
#South-East Asia Region=SEARO
#Western Pacific Region=WPRO

ALGUNOS PAISES DE LATINOAMÉRICA

EL CASO DE COLOMBIA

colombia<-subset(who, who$Country=="Colombia")

gcolombia<-ggplot(colombia, aes(fecha,New_deaths,group=Country))
gcolombia<-gcolombia + geom_line()
gcolombia<-gcolombia + labs(title="Nuevas muertes por Sars Cov2 en Colombia", x="Fecha", y="Nuevas Muertes")
gcolombia<-gcolombia + theme(axis.text.x = element_text(angle=90, size=5, hjust=1))
gcolombia<-gcolombia + scale_x_date(date_breaks = "1 week")
gcolombia

EL CASO DE BRASIL

brasil<-subset(who, who$Country=="Brazil")

gbrasil<-ggplot(brasil, aes(fecha,New_deaths,group=Country))
gbrasil<-gbrasil + geom_line()
gbrasil<-gbrasil + labs(title="Nuevas muertes por Sars Cov2 en Brasil", x="Fecha", y="Nuevas Muertes")
gbrasil<-gbrasil + theme(axis.text.x = element_text(angle=90, size=5, hjust=1))
gbrasil<-gbrasil + scale_x_date(date_breaks = "1 week")
gbrasil

CASO DE COMPARATIVO DE DOS PAISES

BRASIL Y COLOMBIA

brascol<-subset(who, who$Country_code=="BR" | who$Country_code=="CO")

gbrascol<-ggplot(brascol, aes(x=fecha, y=New_deaths, group=Country_code, color=Country_code)) 
gbrascol<-gbrascol + geom_line()
gbrascol<-gbrascol + labs(title="Nuecas Muertes por Sars-Cov2 en Brasil y Colombia", x="Fecha", y="Nuevas Muertes")
gbrascol<-gbrascol + theme(axis.text.x = element_text(angle=90, size=5, hjust=1))
gbrascol<-gbrascol + scale_x_date (date_breaks="1 month")
gbrascol

CAJAS Y BIGOTES

cyb<-subset(who, WHO_region=='AMRO')

gcyb<-ggplot(cyb, aes(New_cases, group=Country_code))
gcyb<-gcyb +  geom_boxplot()
gcyb<-gcyb + labs(title = "Casos Nuevos Latinoamerica")
gcyb