knitr::opts_chunk$set(
  collapse = TRUE,
  dpi=200,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

COVID19AR

A package for analysing COVID-19 Argentina's outbreak

Package

| Release | Usage | Development | |:--------|:------|:------------| | | minimal R version | Travis | | CRAN | | codecov | |||Project Status: Active – The project has reached a stable, usable state and is being actively developed.|

How to get started (Development version)

Install the R package using the following commands on the R console:

The repository is private so it have to be cloned first for installation

# install.packages("devtools")
devtools::install()

How to use it

First add variable with data dir in ~/.Renviron. You will recieve a message if you didn't do it.

COVID19AR_data_dir = "~/.R/COVID19AR"

Example script for calculating proportion of influenza/Neumonia deaths in total deaths by year

library(COVID19AR)
# Downloads csv from official source at:
# http://www.deis.msal.gov.ar/index.php/base-de-datos/
retrieveArgentinasDeathsStatistics()


consolidated.deaths.stats <- ConsolidatedDeathsData.class$new()
# Consolidates all years and includes the different codes as factor in the data frame
data.deaths <- consolidated.deaths.stats$consolidate()

# How many records do we have?
nrow(data.deaths)
# [1] 347549

# Cases with missing codes in CAUSA
kable(consolidated.deaths.stats$warnings)
regexp.neumonia.influenza <- "^J(09|1[0-8])"
regexp.otras.respiratorias <- "^J"

# List all Causas related to Influenza|Neumonía considered for classification

causas.descriptions <- sort(unique(data.deaths$codigo.causas))
causas.descriptions[grep(regexp.neumonia.influenza, causas.descriptions, ignore.case = TRUE)]

data.deaths$causa_agg <- "Otra"
data.deaths[grep(regexp.neumonia.influenza, data.deaths$codigo.causa, ignore.case = TRUE),]$causa_agg <- "Influenza_Neumonia"
data.deaths[which(grepl(regexp.otras.respiratorias, data.deaths$codigo.causa, ignore.case = TRUE) & data.deaths$causa_agg == "Otra"),]$causa_agg <- "Otras_respiratorias"

influenza.deaths <- data.deaths %>%
                      group_by(year, causa_agg) %>%
                      summarize (total = sum(CUENTA),
                                 edad.media = mean(EDAD_MEDIA, na.rm = TRUE))
influenza.deaths %>% filter(year == 2018)

influenza.deaths.tab <- dcast(influenza.deaths, formula = year~causa_agg, value.var = "total")
influenza.deaths.tab$total <- apply(influenza.deaths.tab[,2:4], MARGIN = 1, FUN = sum)
influenza.deaths.tab$Influenza_Neumonia.perc <- round(influenza.deaths.tab[,"Influenza_Neumonia"]/influenza.deaths.tab$total, 2)
influenza.deaths.tab$Otra.perc <- round(influenza.deaths.tab[,"Otra"]/influenza.deaths.tab$total, 2)
influenza.deaths.tab$Otras_respiratorias.perc <- round(influenza.deaths.tab[,"Otras_respiratorias"]/influenza.deaths.tab$total, 2)
kable(influenza.deaths.tab)
influenza.deaths.edad.tab <- dcast(influenza.deaths, formula = year~causa_agg, value.var = "edad.media")
# Edad media is aproximated by the average of the mean of age ranges
kable(influenza.deaths.edad.tab)


rOpenStats/COVID19AR documentation built on Feb. 3, 2022, 10:23 p.m.