Created
March 5, 2024 00:32
-
-
Save paulovillarroel/f37b666b124fc2af15c93ebd585839be to your computer and use it in GitHub Desktop.
Script to download data of respiratory emergency care in Chile and generate a graph for the care for Influenza disease.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(arrow) | |
url <- "https://datos.gob.cl/dataset/606ef5bb-11d1-475b-b69f-b980da5757f4/resource/ae6c9887-106d-4e98-8875-40bf2b836041/download/at_urg_respiratorio_semanal.parquet" | |
download.file(url, "raw-data/at_urg_respiratorio_semanal.parquet", mode = "wb") | |
df <- arrow::read_parquet("raw-data/at_urg_respiratorio_semanal.parquet") | |
influenza_hospitales <- df |> | |
filter( | |
TipoUrgencia == "Urgencia Hospitalaria (UEH)", | |
Causa == "Influenza (J09-J11)" | |
) |> | |
group_by(Anio, SemanaEstadistica) |> | |
summarise(casos = sum(NumTotal)) |> | |
ungroup() |> | |
janitor::clean_names() | |
influenza_hospitales <- influenza_hospitales |> | |
filter(!(anio == 2024 & semana_estadistica == last(semana_estadistica))) | |
ggplot(data = influenza_hospitales, aes(x = semana_estadistica, y = casos, group = factor(anio), color = factor(anio))) + | |
geom_line(linewidth = 0.8) + | |
scale_x_continuous(breaks = seq(min(influenza_hospitales$semana_estadistica), max(influenza_hospitales$semana_estadistica), by = 5)) + | |
scale_color_manual(values = c(rep("#ced4da", times = length(unique(influenza_hospitales$anio)) - 1), "#ff006e")) + | |
labs( | |
title = "Casos de influenza en urgencias hospitalarias", | |
subtitle = "Año 2024 resaltado", | |
x = "Semana epidemiológica", | |
y = "Casos", | |
color = "Año", | |
caption = "datos.gob.cl | MINSAL" | |
) + | |
theme_minimal() + | |
theme(legend.position = "none") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment