Sin categoría

Covid19

Publicada en

Este documento es un ejercicio de análisis de datos usando R. No pretende ser una fuente de información ni un análisis de la situación actual.

Se incluye el código fuente para su uso con las reservas pertinentes.

Fuente de datos sobre el Covi19: https://ourworldindata.org/

df = read_csv("https://covid.ourworldindata.org/data/ecdc/full_data.csv")
## Parsed with column specification:
## cols(
##   date = col_date(format = ""),
##   location = col_character(),
##   new_cases = col_double(),
##   new_deaths = col_double(),
##   total_cases = col_double(),
##   total_deaths = col_double()
## )
df = df %>% rename(Pais = location) %>% rename(AcumuladoCasos = total_cases) %>% rename(AcumuladoMuertes = total_deaths) %>% rename(Casos = new_cases) %>% rename(Muertes = new_deaths)

df <- df %>%
filter(Pais %in% c("Mexico", "Brazil", "China", "Italy", "Spain", "United States", "South Korea ")) %>%
filter(AcumuladoCasos>0)
fecha <- max(df$date)
df1 <- df %>%
  dplyr::group_by(Pais) %>%
  dplyr::summarise(Casos = sum(Casos), Decesos=sum(Muertes))
paste("<h1>Fecha de corte ", fecha,  sep = "")
## [1] "<h1>Fecha de corte 2020-04-10"
paste("</h1>")
## [1] "</h1>"
kable(df1) %>%
  kable_styling(bootstrap_options = "striped", full_width = F)%>%
  add_header_above(c("Casos de Covid19 reportados" = 3))
Casos de Covid19 reportados
Pais Casos Decesos
Brazil 17857 941
China 82925 3340
Italy 143626 18281
Mexico 3441 194
Spain 152446 15238
United States 466033 16690
df2 <- df %>%
filter(Pais %in% c("Mexico"))

qplot(date,Casos,data=df, color = as.factor(Pais), geom=c("point", "line"), 
  main = "Casos confirmados nuevos",
  xlab = "Fecha",
  ylab = "Casos")

qplot(date,AcumuladoCasos,data=df, color = as.factor(Pais), geom=c("point", "line"), 
  facets = .~ Pais,
  main = "Casos confirmados totales",
  xlab = "Fecha",
  ylab = "Casos")

qplot(factor(Pais), AcumuladoCasos , data = df, 
      geom = "violin", stackdir = "center", binaxis = "y",
      color = factor(Pais), fill = factor(Pais),
      main = "Casos totales",
      xlab = "Fecha",
      ylab = "Casos confirmados totales")
## Warning: Ignoring unknown parameters: stackdir, binaxis

qplot(date,log(AcumuladoCasos),data=df, color = as.factor(Pais), geom=c("point", "line"),
      main = "Curvas de crecimiento",
      xlab = "Fecha",
      ylab = "logaritmo de casos totales")

qplot(date,Casos,data=df2, geom=c("point", "line"), 
  main = "Mexico",
  xlab = "Fecha",
  ylab = "Casos confirmados nuevos")

qplot(date,AcumuladoCasos,data=df2, geom=c("point", "line"), 
  facets = .~ Pais,
  main = "Mexico",
  xlab = "Fecha",
  ylab = "Casos confirmados totales")

qplot(date,log(AcumuladoCasos),data=df2, geom=c("point", "line"), 
  facets = .~ Pais,
  main = "Mexico",
  xlab = "Fecha",
  ylab = "Logaritmo de Casos confirmados totales")

df2 <- df %>%
filter(Pais %in% c("United States"))

qplot(date,Casos,data=df2, geom=c("point", "line"), 
  main = "United States",
  xlab = "Fecha",
  ylab = "Casos confirmados nuevos")