Descargar el data set aquí , Fuente OMS.
# Preparando la data
covid_19 <- read.csv("D:/curso_analisis/COVID_19/WHO-COVID-19-global-data.csv", header = TRUE,sep=",")
covid_19$ï..Date_reported<-as.Date(covid_19$ï..Date_reported)
str(covid_19)
## 'data.frame': 121581 obs. of 8 variables:
## $ ï..Date_reported : Date, format: "2020-01-03" "2020-01-04" ...
## $ 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 ...
# Prepare data
covid_19 <- read.csv("WHO-COVID-19-global-data.csv", header = TRUE,sep=",")
covid_19$ï..Date_reported<-as.Date(covid_19$ï..Date_reported)
str(covid_19)
## 'data.frame': 121581 obs. of 8 variables:
## $ ï..Date_reported : Date, format: "2020-01-03" "2020-01-04" ...
## $ 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 ...
plotBase2 <- ggplot(covid_19, aes(ï..Date_reported, New_cases, fill=WHO_region))
plotBase2 <- plotBase2 + geom_bar(stat="identity")
# accommodate labels
plotBase2 <- plotBase2 + labs(title = "Nuevos casos de COVID-19 a nivel mundial ", x= "Dias", y="Casos nuevos")
plotBase2 <- plotBase2 + theme(axis.text.x = element_text(angle = 90, size = 6, hjust = 1))
# plot chart
plotBase2
plotBase3<-plotBase2
plotBase3<- plotBase3 + facet_grid(WHO_region~. )
plotBase3
Colombia<-subset(covid_19, covid_19$Country == "Colombia")
plot_colombia <- ggplot(Colombia, aes(ï..Date_reported, New_cases, group=Country))
plot_colombia <- plot_colombia + geom_line()
# accommodate labels
plot_colombia <- plot_colombia + labs(title = "Nuevos casos de COVID-19 en Colombia ", x= "Dias", y="Casos nuevos")
plot_colombia <- plot_colombia + theme(axis.text.x = element_text(angle = 90, size = 6, hjust = 1)) +
scale_x_date(date_breaks = "1 week")
# plot chart
plot_colombia
CyB<-subset(covid_19, covid_19$Country == "Colombia" | covid_19$Country == "Brazil")
plot_cyb <- ggplot(CyB, aes(ï..Date_reported, New_cases, group=Country, color=Country))
plot_cyb <- plot_cyb + geom_line()
# accommodate labels
plot_cyb <- plot_cyb + labs(title = "Nuevos casos de COVID-19 en Colombia y Brazil ", x= "Dias", y="Casos nuevos")
plot_cyb <- plot_cyb + theme(axis.text.x = element_text(angle = 90, size = 6, hjust = 1)) +
scale_x_date(date_breaks = "1 week")
# plot chart
plot_cyb
Caso para latinoamerica:
latinoamerica <- subset(covid_19, covid_19$WHO_region=='AMRO')
graf_barras <- ggplot(latinoamerica, aes(New_cases, group=Country_code))
#graf_barras <- graf_barras + geom_line(color='blue')
#graf_barras <- graf_barras + geom_density (stat='identity')
graf_barras <- graf_barras + geom_boxplot ()
graf_barras <- graf_barras + labs(title="Casos Nuevos en LATAM")
graf_barras