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

fix: report template, title, plots and logic for multiple diseases #66

Closed
wants to merge 70 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
878b097
adding conditional for single color in plot by variable (#20)
GeraldineGomez Feb 1, 2023
f51defa
modify conditional of var_fill (#21)
GeraldineGomez Feb 1, 2023
1ae7b87
modify dengue example and plot by variables (#23)
GeraldineGomez Feb 1, 2023
a7c4428
modify text size and color of plot by variable (#24)
GeraldineGomez Feb 1, 2023
9ce2374
updating text size plot
GeraldineGomez Feb 2, 2023
1e55550
automation porcentage of ages and total cases, correction of graphs (…
GeraldineGomez Feb 2, 2023
b02316f
automation of total cases and correction of graphs (#26)
GeraldineGomez Feb 2, 2023
a4776bf
updating var_fill
GeraldineGomez Feb 2, 2023
36f4b1f
restoring parameters function
GeraldineGomez Feb 2, 2023
837948a
updating single color plot by variable
GeraldineGomez Feb 2, 2023
b880f54
update lifecycle RECON in README file
GeraldineGomez Jun 20, 2023
56d9dd6
update lifecycle to maturing in README file
GeraldineGomez Jun 21, 2023
6ea2937
update and add functions of subnational report and package documentat…
GeraldineGomez Jun 23, 2023
cc2ed21
Merge remote-tracking branch 'origin/main' into dev
GeraldineGomez Jun 23, 2023
d3fe0a9
fix: code style and indentation (#33)
GeraldineGomez Jun 24, 2023
6541018
update functions and documentation of subnational report (#34)
GeraldineGomez Jun 24, 2023
c142897
fix: import and plot functions (#38)
GeraldineGomez Jul 9, 2023
f560b3e
Merge branch 'main' into dev
GeraldineGomez Jul 9, 2023
798d42d
Set up pkgdown website (#37)
Bisaloo Jul 10, 2023
cacd14c
translation to Spanish of functions, documentation and vignettes (#39)
GeraldineGomez Jul 20, 2023
ca29381
updating documentation with the new package logo (#40)
GeraldineGomez Jul 24, 2023
3d899ec
Merge branch 'main' into dev
GeraldineGomez Jul 24, 2023
6ff0413
fix: disease o event title on skeleton Reporte Basico
GeraldineGomez Jul 25, 2023
1fc5d19
fix: description of temporal distribution, sex and conclusion sections
GeraldineGomez Jul 27, 2023
af8cd42
adding multiple diseases import, plot and group
GeraldineGomez Jul 27, 2023
2b2373f
fix descriptions of report template sections and adding multiple grou…
GeraldineGomez Jul 27, 2023
d81044b
adding nombre_evento to agrupar_cols_casos
GeraldineGomez Jul 27, 2023
ab3ff3e
adding multiple diseases to agrupar_cols_casos (#43)
GeraldineGomez Jul 27, 2023
7daeba7
fix: temporal section month with most cases and validation of malaria…
GeraldineGomez Jul 27, 2023
f3774f6
adding validation to mortalidad event
GeraldineGomez Jul 27, 2023
987185d
Merge branch 'dev' into fix-report-template
GeraldineGomez Jul 27, 2023
b006ef8
Merge branch 'dev' into fix-report-template
GeraldineGomez Jul 27, 2023
011b611
adding validation to mortalidad event (#45)
GeraldineGomez Jul 27, 2023
acddf4d
adding condition of validation mortality
GeraldineGomez Jul 27, 2023
e44aa3d
Merge branch 'dev' into fix-report-template
GeraldineGomez Jul 27, 2023
285a388
Fix report template (#46)
GeraldineGomez Jul 27, 2023
a2bcd32
updating plot multiple disease and vignettes
GeraldineGomez Jul 27, 2023
1d9cbff
updating plotting for multiples diseases (#48)
GeraldineGomez Jul 27, 2023
67f07bf
remove whitespace
GeraldineGomez Jul 27, 2023
808ea22
updating generic plotting function for multiple disease visualisation
GeraldineGomez Jul 27, 2023
f896166
updating visualisation function for multiple diseases (#49)
GeraldineGomez Jul 27, 2023
0be4f85
fixing whitespaces
GeraldineGomez Jul 27, 2023
a36dc5e
fix: whitespace on report basic template (#50)
GeraldineGomez Jul 27, 2023
c2e0ee1
fix conditional of morbility on skeleton
GeraldineGomez Jul 27, 2023
87120ff
updating conditional of morbility on skeleton
GeraldineGomez Jul 27, 2023
561e1c1
fix condition of morbility (#51)
GeraldineGomez Jul 27, 2023
511f23a
change col(s)_nombre(s) to column and review all parameters
GeraldineGomez Aug 3, 2023
4b82101
change col(s)_nombre(s) to column and review all parameters
GeraldineGomez Aug 3, 2023
a7f2b16
change col_dpto and dpt to dpto, col_mun and nombre_mun to munpio, co…
GeraldineGomez Aug 3, 2023
8bf50c6
change col(s)_nombre(s) to column and review all parameters
GeraldineGomez Aug 3, 2023
6fd1852
ordering results of agrupar_mun by cases
GeraldineGomez Aug 6, 2023
874ec06
adding update year of SIVIGILA microdata
GeraldineGomez Aug 6, 2023
df9fe46
remove position dogde of generic function plot_variable
GeraldineGomez Aug 6, 2023
fe4d11b
adding code event as column in obtener_tip_ocurren_geo
GeraldineGomez Aug 6, 2023
0adc006
fix: example disease
GeraldineGomez Aug 6, 2023
a158df0
adding in config file related diseases
GeraldineGomez Aug 6, 2023
18cc8e9
adding package logo in header and footer
GeraldineGomez Aug 6, 2023
2e539b2
fixing scale colours and adding title and subtitle of map plot
GeraldineGomez Aug 23, 2023
5334fe8
fix process and implicated functions to import event data (#56)
GeraldineGomez Sep 29, 2023
ca7b05d
fix (import_data): updating functions related to import and clean pro…
GeraldineGomez Sep 29, 2023
e455721
fix (import_data): updating functions related to sex semana epi compo…
GeraldineGomez Sep 29, 2023
202e1e1
fix (import_data): remove sca problems (#59)
GeraldineGomez Sep 29, 2023
3150af2
fix (import_data): remove whitespace (#60)
GeraldineGomez Sep 29, 2023
5ae7592
fix (plot_map): adding logic to multiple events
gsgomezm Oct 2, 2023
aacfb44
fix and docs: updating, clean and name chunks of vignettes and README…
GeraldineGomez Oct 2, 2023
d8ca3d4
test and chore: adding example test data and updating the documentati…
GeraldineGomez Oct 3, 2023
24721ab
Merge remote-tracking branch 'origin/main' into dev
gsgomezm Oct 3, 2023
fff288b
fix: data, examples and nombre_evento parameter of report template (#64)
GeraldineGomez Oct 3, 2023
c3eba46
fix: data example, import data function and documentation (#65)
GeraldineGomez Oct 3, 2023
c7f02e2
Merge branch 'dev' of https://github.com/epiverse-trace/sivirep into …
gsgomezm Oct 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ Type: Package
Version: 0.0.2.0
Authors@R:
c(
person("Zulma M. Cucunubá", role = "aut"),
person("Geraldine Gómez Millán", role = c("aut", "cre"),
email = "[email protected]")
person(given = "Geraldine", family = "Gómez Millán", email = "[email protected]", role = c("aut", "cre", "ctb"),
comment = c(ORCID = "https://orcid.org/0009-0007-8701-0568")),
person(given = "Zulma M.", family = "Cucunubá", email = "[email protected]", role = c("aut", "ctb"),
comment = c(ORCID = "https://orcid.org/0000-0002-8165-3198")),
person(given = "Hugo", family = "Gruson", email = "[email protected]", role = c("ctb"),
comment = c(ORCID = "https://orcid.org/0000-0002-4094-1476")),
person(given = "Laura", family = "Gómez Bermeo", email = "[email protected]", role = c("ctb"),
comment = c(ORCID = "https://orcid.org/0000-0003-4028-2893")),
person(given = "Miguel", family = "Gámez", role = c("ctb")),
person(given = "Jennifer", family = "Méndez-Romero", role = c("ctb")),
person(given = "Johan", family = "Calderón", role = c("ctb")),
person(given = "Lady", family = "Flórez-Tapiero", role = c("ctb")),
person(given = "Verónica", family = "Tangarife-Arredondo", role = c("ctb"))
)
Description: Provides functions for data wrangling and automated reports
from SIVIGILA source.
Expand All @@ -23,10 +33,12 @@ Imports:
stringr,
xml2,
epitrix,
sf
sf,
readxl
Suggests:
knitr,
rmarkdown
Depends: R (>= 2.10)
Config/Needs/website:
epiverse-trace/epiversetheme
VignetteBuilder: knitr
263 changes: 144 additions & 119 deletions R/checking_data.R

Large diffs are not rendered by default.

103 changes: 58 additions & 45 deletions R/cleaning_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
#' @return Un data frame que contiene los códigos geográficos estandarizados
#' de los datos de una enfermedad o evento
#' @examples
#' data_event <- import_data_event(2019, "DENGUE")
#' data_event <- limpiar_encabezado(data_event)
#' data(dengue2020)
#' data_event <- dengue2020
#' data_event <- limpiar_data_sivigila(data_event, 2020)
#' estandarizar_geo_cods(data_event = data_event)
#' @export
estandarizar_geo_cods <- function(data_event) {
Expand Down Expand Up @@ -49,8 +50,9 @@ estandarizar_geo_cods <- function(data_event) {
#' @examples
#' geo_cods <- import_geo_cods()
#' depto_cods <- obtener_cods_dpto(geo_cods)
#' data_event <- import_data_event(2019, "DENGUE")
#' data_event <- limpiar_encabezado(data_event)
#' data(dengue2020)
#' data_event <- dengue2020
#' data_event <- limpiar_data_sivigila(data_event, 2020)
#' data_agrupada <- agrupar_cols_casos(data_event,
#' "cod_dpto_o",
#' agr_porcentaje = TRUE)
Expand Down Expand Up @@ -91,8 +93,9 @@ limpiar_cods_event_dpto <- function(depto_cods,
#' de los datos de una enfermedad o evento
#' @examples
#' geo_codes <- import_geo_cods()
#' data_event <- import_data_event(2019, "DENGUE")
#' data_event <- limpiar_encabezado(data_event)
#' data(dengue2020)
#' data_event <- dengue2020
#' data_event <- limpiar_data_sivigila(data_event, 2020)
#' limpiar_cods_dpto(data_event = data_event,
#' col_cods_data = "cod_dpto_o",
#' geo_data = geo_codes,
Expand Down Expand Up @@ -136,15 +139,18 @@ limpiar_cods_dpto <- function(data_event,
#' @return Un data framecon las edades en años según las unidades de medida
#' del SIVIGILA
#' @examples
#' data_event <- import_data_event(2019, "DENGUE")
#' data_event <- limpiar_encabezado(data_event)
#' data(dengue2020)
#' data_event <- dengue2020
#' data_event <- limpiar_data_sivigila(data_event, 2020)
#' convert_edad(data_event = data_event,
#' col_edad = "edad",
#' col_uni_med = "uni_med")
#' @export
convert_edad <- function(data_event,
col_edad = "edad",
col_uni_med = "uni_med") {
data_event$uni_med <- as.numeric(data_event$uni_med)
data_event$edad <- as.numeric(data_event$edad)
data_event_years <-
dplyr::mutate(data_event,
edad =
Expand Down Expand Up @@ -173,16 +179,17 @@ convert_edad <- function(data_event,
#' incluyen NA, Infinito o NaN
#' @param data_event Un data frame que contiene los datos de una
#' enfermedad o evento
#' @param nom_col Un character (cadena de caracteres) que contiene el
#' @param column Un character (cadena de caracteres) que contiene el
#' nombre de la columna en los datos de una enfermedad o evento a evaluar
#' @return Los datos limpios sin valores NA, Infinito o NaN
#' @examples
#' data_event <- import_data_event(2019, "DENGUE")
#' data_event <- limpiar_encabezado(data_event)
#' data(dengue2020)
#' data_event <- dengue2020
#' data_event <- limpiar_data_sivigila(data_event, 2020)
#' remove_val_nin(data_event = data_event, nom_col = "edad")
#' @export
remove_val_nin <- function(data_event, nom_col) {
ref_col <- paste0("data_event$", nom_col)
remove_val_nin <- function(data_event, column) {
ref_col <- paste0("data_event$", column)
data_event_del <- data_event
del_rows <-
which(ifelse(is.na(eval(parse(text = ref_col))), TRUE,
Expand All @@ -206,8 +213,9 @@ remove_val_nin <- function(data_event, nom_col) {
#' @return Un data framecon los datos sin las fechas mayores que el
#' valor de comparación
#' @examples
#' data_event <- import_data_event(2019, "DENGUE")
#' data_event <- limpiar_encabezado(data_event)
#' data(dengue2020)
#' data_event <- dengue2020
#' data_event <- limpiar_data_sivigila(data_event, 2020)
#' remove_error_fecha(data_event = data_event,
#' col_ini = "ini_sin",
#' col_comp = "fec_hos")
Expand All @@ -229,24 +237,24 @@ remove_error_fecha <- function(data_event,
#' de un evento o enfermedad
#' @param format_fecha Un character (cadena de caracteres)
#' que contiene el formato deseado de fecha
#' @param nombres_col Un character (cadena de caracteres) que
#' @param columns Un character (cadena de caracteres) que
#' contiene los nombres de la columna a formatear
#' @return Un data framecon los datos con las fechas formateadas
#' @examples
#' data_event <- import_data_event(2020, "DENGUE")
#' data_event <- format_fecha(data_event)
#' data_event <- limpiar_data_sivigila(data_event, 2020)
#' format_fecha(data_event = data_event,
#' format_fecha = "%AAAA-%MM-%DD",
#' nombres_col = c("ini_sin", "fec_hos"))
#' format_fecha = "%Y-%m-%d",
#' columns = c("ini_sin", "fec_hos"))
#' @export
format_fecha <- function(data_event,
format_fecha = "%AAAA-%MM-%DD",
format_fecha = "%Y-%m-%d",
nombres_col = c()) {
data_event_limp <- data_event
for (name in nombres_col) {
for (name in columns) {
if (!is.null(name)) {
ref_col <- eval(parse(text = paste0("data_event_limp$", name)))
ref_col <- as.Date(ref_col, format = format_fecha)
data_event_limp[[name]] <- as.Date(data_event[[name]],
format = format_fecha)
}
}
return(data_event_limp)
Expand All @@ -261,7 +269,8 @@ format_fecha <- function(data_event,
#' @return Un data framecon las etiquetas del encabezado formateadas
#' con guión bajo (_)
#' @examples
#' data_event <- import_data_event(2019, "DENGUE")
#' data(dengue2020)
#' data_event <- dengue2020
#' limpiar_encabezado(data_event = data_event)
#' @export
limpiar_encabezado <- function(data_event) {
Expand All @@ -278,38 +287,38 @@ limpiar_encabezado <- function(data_event) {
#' de una enfermedad o evento
#' @param format_fecha Un character (cadena de caracteres) que contiene
#' el formato deseado de fecha; su valor por defecto es "\%AAAA-\%MM-\%DD"
#' @param nombre_col Un character (cadena de caracteres) que contiene
#' @param column Un character (cadena de caracteres) que contiene
#' el nombre de la columna del conjunto de datos
#' @param col_comp Un character (cadena de caracteres) que contiene el
#' nombre de la columna de comparación del conjunto de datos
#' @return Un data framecon los datos con las fechas limpias
#' @examples
#' data_event <- import_data_event(2020, "DENGUE")
#' data_event <- limpiar_encabezado(data_event)
#' data_event <- limpiar_data_sivigila(data_event, 2020)
#' limpiar_fecha_event(data_event = data_event,
#' year = 2020,
#' format_fecha = "%AAAA-%MM-%DD",
#' format_fecha = "%Y-%m-%d",
#' nombre_col = "ini_sin",
#' col_comp = "fec_hos")
#' @export
limpiar_fecha_event <- function(data_event,
year,
format_fecha = "%AAAA-%MM-%DD",
format_fecha = "%Y-%m-%d",
nombre_col = "ini_sin",
col_comp = NULL) {
data_event_fecha_ini <- data_event
if (!is.null(col_comp)) {
data_event_fecha_ini <-
remove_error_fecha(data_event_fecha_ini,
nombre_col,
column,
col_comp)
}
data_event_fecha_ini[order(eval(parse(text =
paste0("data_event_fecha_ini$",
nombre_col))),
column))),
decreasing = TRUE), ]
data_event_fecha_ini <- data_event_fecha_ini[format(eval(
parse(text = paste0("data_event_fecha_ini$", nombre_col))
parse(text = paste0("data_event_fecha_ini$", column))
), "%Y") == year, ]
return(data_event_fecha_ini)
}
Expand All @@ -319,19 +328,19 @@ limpiar_fecha_event <- function(data_event,
#' Función que limpia las edades de los datos de una enfermedad o evento
#' @param data_event Un data frame que contiene los datos de una
#' enfermedad o evento
#' @param nombre_col Un character (cadena de caracteres) con el nombre
#' @param column Un character (cadena de caracteres) con el nombre
#' de la columna de los datos que contiene las edades;
#' su valor por defecto es edad
#' @return Un data framecon los datos de una enfermedad o evento
#' con las edades limpias
#' @examples
#' data_event <- import_data_event(2020, "DENGUE")
#' data_event <- limpiar_encabezado(data_event)
#' data_event <- limpiar_data_sivigila(data_event, 2020)
#' limpiar_edad_event(data_event = data_event, nombre_col = "edad")
#' @export
limpiar_edad_event <- function(data_event, nombre_col = "edad") {
limpiar_edad_event <- function(data_event, column = "edad") {
data_event_years <- convert_edad(data_event)
data_event_years <- remove_val_nin(data_event_years, nombre_col)
data_event_years <- remove_val_nin(data_event_years, column)
}

#' Limpiar los valores atipicos de los datos
Expand All @@ -358,8 +367,8 @@ limpiar_val_atipic <- function(data_event) {
code <- names(event)
if (cod_event %in% code) {
cols <- event[as.character(cod_event)]
for (nom_cols in cols) {
for (col in nom_cols) {
for (columns in cols) {
for (col in columns) {
data_event[eval(parse(text = col))] <- NA
}
}
Expand All @@ -376,7 +385,7 @@ limpiar_val_atipic <- function(data_event) {
#' una enfermedad o evento
#' @param year Un numeric (numerico) que contiene el año de los
#' datos de una enfermedad o evento
#' @return Un data framecon los datos limpios de la enfermedad o evento
#' @return Un data frame con los datos limpios de la enfermedad o evento
#' @examples
#' year <- 2019
#' data_event <- import_data_event(year, "DENGUE")
Expand All @@ -385,17 +394,21 @@ limpiar_val_atipic <- function(data_event) {
limpiar_data_sivigila <- function(data_event, year) {
data_event <- limpiar_encabezado(data_event)
data_event <- limpiar_edad_event(data_event)
nom_cols_fechas <- config::get(file = system.file("extdata",
columns_fechas <- config::get(file = system.file("extdata",
"config.yml",
package = "sivirep"),
"dates_column_names")
data_event_limp <- format_fecha(data_event,
nombres_col = nom_cols_fechas)
data_event_limp <- limpiar_fecha_event(data_event_limp, year,
nombre_col = nom_cols_fechas[3],
col_comp = nom_cols_fechas[4])
data_event_limp <- limpiar_fecha_event(data_event_limp, year,
nombre_col = nom_cols_fechas[2])
columns = columns_fechas)
nombre <- unique(data_event$nombre_evento)
if (length(nombre) == 1 && !stringr::str_detect(nombre, "MORTALIDAD")) {
if (length(nombre) == 1 && !stringr::str_detect(nombre, "MORTALIDAD")) {
data_event_limp <- limpiar_fecha_event(data_event_limp, year,
column = columns_fechas[3],
col_comp = columns_fechas[4])
data_event_limp <- limpiar_fecha_event(data_event_limp, year,
column = columns_fechas[2])
}
data_event_limp <- estandarizar_geo_cods(data_event_limp)
data_event_limp <- convert_edad(data_event_limp,
col_edad = "edad",
Expand Down
15 changes: 15 additions & 0 deletions R/dengue2020.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#' Datos Dengue 2020 en sivirep
#'
#' Data from
#'
#' @docType data
#'
#' @usage dengue2020
#'
#' @format An object of class \code{"cross"}; see \code{\link[qtl]{read.cross}}.
#'
#' @keywords datasets
#'
#' @examples
#' dengue2020
"dengue2020"
Loading