Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigación positividad, UCI respiradores y letalidad por provincia #1

Open
kenarab opened this issue May 30, 2020 · 0 comments
Open
Labels

Comments

@kenarab
Copy link
Collaborator

kenarab commented May 30, 2020

library(COVID19AR)
#> Loading required package: dplyr
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
#> Loading required package: knitr
#> Loading required package: magrittr
#> Loading required package: lgr
#> Warning: replacing previous import 'ggplot2::Layout' by 'lgr::Layout' when
#> loading 'COVID19AR'
#> Warning: replacing previous import 'readr::col_factor' by 'scales::col_factor'
#> when loading 'COVID19AR'
#> Warning: replacing previous import 'magrittr::equals' by 'testthat::equals' when
#> loading 'COVID19AR'
#> Warning: replacing previous import 'magrittr::not' by 'testthat::not' when
#> loading 'COVID19AR'
#> Warning: replacing previous import 'magrittr::is_less_than' by
#> 'testthat::is_less_than' when loading 'COVID19AR'
#> Warning: replacing previous import 'dplyr::matches' by 'testthat::matches' when
#> loading 'COVID19AR'
library(ggplot2)
#> 
#> Attaching package: 'ggplot2'
#> The following object is masked from 'package:lgr':
#> 
#>     Layout
#library(dplyr)
#library(RColorBrewer)
knitr::opts_chunk$set(fig.width = 4, fig.height = 6, dpi = 300, warning = FALSE)
report.dir = file.path(getEnv("data_dir"), "reports")
dir.create(report.dir, showWarnings = FALSE, recursive = TRUE)
covid19.curator <- COVID19ARCurator$new(download.new.data = FALSE)
dummy <- covid19.curator$loadData()
#> INFO  [22:13:57.370] Exists dest path? {dest.path: ~/.R/COVID19AR/Covid19Casos.csv, exists.dest.path: TRUE}
dummy <- covid19.curator$curateData()
#> INFO  [22:13:59.087] Normalize 
#> INFO  [22:13:59.497] checkSoundness 
#> INFO  [22:13:59.631] Mutating data

covid19.ar.provincia.summary <- covid19.curator$makeSummary(group.vars = c("residencia_provincia_nombre"))
covid19.ar.provincia.summary.selected <- covid19.ar.provincia.summary %>% filter(confirmados >= 100)

covid19.ar.summary <- covid19.curator$makeSummary(group.vars = c("residencia_provincia_nombre", "sepi_apertura"))
#> INFO  [22:14:28.550] Processing {current.group: residencia_provincia_nombre = Buenos Aires}
#> INFO  [22:14:31.253] Processing {current.group: residencia_provincia_nombre = CABA}
#> INFO  [22:14:33.580] Processing {current.group: residencia_provincia_nombre = Catamarca}
#> INFO  [22:14:35.117] Processing {current.group: residencia_provincia_nombre = Chaco}
#> INFO  [22:14:37.325] Processing {current.group: residencia_provincia_nombre = Chubut}
#> INFO  [22:14:39.742] Processing {current.group: residencia_provincia_nombre = Córdoba}
#> INFO  [22:14:41.927] Processing {current.group: residencia_provincia_nombre = Corrientes}
#> INFO  [22:14:44.410] Processing {current.group: residencia_provincia_nombre = Entre Ríos}
#> INFO  [22:14:46.250] Processing {current.group: residencia_provincia_nombre = Formosa}
#> INFO  [22:14:48.418] Processing {current.group: residencia_provincia_nombre = Jujuy}
#> INFO  [22:14:50.413] Processing {current.group: residencia_provincia_nombre = La Pampa}
#> INFO  [22:14:52.316] Processing {current.group: residencia_provincia_nombre = La Rioja}
#> INFO  [22:14:54.291] Processing {current.group: residencia_provincia_nombre = Mendoza}
#> INFO  [22:14:57.068] Processing {current.group: residencia_provincia_nombre = Misiones}
#> INFO  [22:14:59.214] Processing {current.group: residencia_provincia_nombre = Neuquén}
#> INFO  [22:15:00.771] Processing {current.group: residencia_provincia_nombre = Río Negro}
#> INFO  [22:15:02.263] Processing {current.group: residencia_provincia_nombre = Salta}
#> INFO  [22:15:03.859] Processing {current.group: residencia_provincia_nombre = San Juan}
#> INFO  [22:15:05.383] Processing {current.group: residencia_provincia_nombre = San Luis}
#> INFO  [22:15:06.783] Processing {current.group: residencia_provincia_nombre = Santa Cruz}
#> INFO  [22:15:08.262] Processing {current.group: residencia_provincia_nombre = Santa Fe}
#> INFO  [22:15:09.956] Processing {current.group: residencia_provincia_nombre = Santiago del Estero}
#> INFO  [22:15:11.386] Processing {current.group: residencia_provincia_nombre = SIN ESPECIFICAR}
#> INFO  [22:15:12.993] Processing {current.group: residencia_provincia_nombre = Tierra del Fuego}
#> INFO  [22:15:14.540] Processing {current.group: residencia_provincia_nombre = Tucumán}

data2plot <- covid19.ar.summary %>%
 filter(residencia_provincia_nombre %in% covid19.ar.provincia.summary.selected$residencia_provincia_nombre) %>%
 filter(confirmados > 0 ) %>%
 filter(positividad.porc <=0.6 | confirmados >= 20)

sepi.fechas <- covid19.curator$data %>%
                 group_by(sepi_apertura) %>%
                 summarize(ultima_fecha_sepi = max(fecha_apertura), .groups = "keep")
data2plot %<>% inner_join(sepi.fechas, by = "sepi_apertura")
dates <- sort(unique(data2plot$ultima_fecha_sepi))
total.dates <- length(dates)

report.date <- max(dates)


covplot <- data2plot %>%
  ggplot(aes(x = ultima_fecha_sepi, y = confirmados, color = "confirmados")) +
  geom_line() +
  facet_wrap(~residencia_provincia_nombre, ncol = 2, scales = "free_y") +
  labs(title = "Evolución de casos confirmados y tests\n en provincias > 100 confirmados")
covplot <- covplot +
  geom_line(aes(x = ultima_fecha_sepi, y = tests, color = "tests")) +
  facet_wrap(~residencia_provincia_nombre, ncol = 2, scales = "free_y")
covplot <- setupTheme(covplot, report.date = report.date, x.values = dates, x.type = "dates",
                      total.colors = 2,
                      data.provider.abv = "@msalnacion", base.size = 6)
covplot <- covplot + scale_y_log10()
#> Scale for 'y' is already present. Adding another scale for 'y', which will
#> replace the existing scale.
covplot

ggsave(file.path(report.dir, paste("provincias-confirmados-tests",".png", sep ="")),
       covplot,
       width = 7, height = 5, dpi = 300)


covplot <- data2plot %>%
 ggplot(aes(x = ultima_fecha_sepi, y = positividad.porc, color = "positividad.porc")) +
 geom_line() +
 facet_wrap(~residencia_provincia_nombre, ncol = 2, scales = "free_y") +
 labs(title = "Porcentajes de positividad, uso de UCI, respirador y letalidad\n en provincias > 100 confirmados")
covplot <- covplot +
 geom_line(aes(x = ultima_fecha_sepi, y = cuidado.intensivo.porc, color = "cuidado.intensivo.porc")) +
 facet_wrap(~residencia_provincia_nombre, ncol = 2, scales = "free_y")
covplot <- covplot  +
 geom_line(aes(x = ultima_fecha_sepi, y = respirador.porc, color = "respirador.porc"))+
 facet_wrap(~residencia_provincia_nombre, ncol = 2, scales = "free_y")
covplot <- covplot +
 geom_line(aes(x = ultima_fecha_sepi, y = letalidad.min.porc, color = "letalidad.min.porc")) +
 facet_wrap(~residencia_provincia_nombre, ncol = 2, scales = "free_y")

covplot <- setupTheme(covplot, report.date = report.date, x.values = dates, x.type = "dates",
                     total.colors = 4,
                     data.provider.abv = "@msalnacion", base.size = 6)
covplot

ggsave(file.path(report.dir, paste("provincias-positividad",".png", sep ="")),
       covplot,
       width = 7, height = 5, dpi = 300)

Created on 2020-06-15 by the reprex package (v0.3.0)

@kenarab kenarab added the RR label May 30, 2020
@kenarab kenarab changed the title Investigación Cuidados Intensivos Investigación Cuidados Intensivos, respiradores y letalidad por provincia Jun 4, 2020
@kenarab kenarab changed the title Investigación Cuidados Intensivos, respiradores y letalidad por provincia Investigación positividad, UCI respiradores y letalidad por provincia Jun 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant