diff --git a/R/checking_data.R b/R/checking_data.R index ec49d40..86c3627 100644 --- a/R/checking_data.R +++ b/R/checking_data.R @@ -938,28 +938,49 @@ get_results_tosferina <- function(report_data, results = "positivo", return(data_grouped) } -#' @title Obtener los tiempos epidemiologicos de los datos historicos + + + + + +#' @title Obtener tiempos epidemiológicos de datos históricos +#' +#' @description +#' Transforma la tabla de la base de datos 'VIRUS RESPIRATORIOS 2022 A 2024' +#' para generar 2 tablas que facilitan las operaciones para las funciones de visualización. +#' Se crea una tabla con los datos adecuados para un gráfico de línea. +#' Se crea una tabla con las columnas adecuadas para un gráfico de barras apiladas. +#' +#' @param dataset_epi_times Data frame con datos históricos que incluyen las columnas +#' `ano`, `periodo_epidemiologico`, `de_positividad` y las de distintos tipos de virus. +#' +#' @return Una lista con dos data frames: +#' - `stacked_data`: Datos en formato largo con tipo de virus y número de casos por semana. +#' - `line_data`: Serie de tiempo con la positividad semanal. +#' #' @export -get_historic_epi_times <- function(tabla) { - data <- tabla - stacked_data <- data %>% +get_historic_epi_times <- function(dataset_epi_times) { + dataset <- dataset_epi_times + stacked_dataset <- dataset %>% tidyr::pivot_longer(cols = .data$a_h1n1_pdm09:.data$otros_virus, - names_to = "Virus_Type", - values_to = "Cases") %>% + names_to = "Virus_Type", + values_to = "Cases") %>% dplyr::mutate(YearWeek = paste(.data$ano, sprintf("%02d", .data$periodo_epidemiologico), sep = "-")) - # Prepare line data for the line chart, ensuring YearWeek is created consistently - line_data <- data %>% + # Prepare line dataset for the line chart, ensuring YearWeek is created consistently + line_dataset <- dataset %>% dplyr::mutate(YearWeek = paste(.data$ano, sprintf("%02d", - .data$periodo_epidemiologico), - sep = "-")) %>% + .data$periodo_epidemiologico), + sep = "-")) %>% dplyr::select(.data$YearWeek, Percent_Positivity = - .data$de_positividad) %>% + .data$percent_de_positividad) %>% tidyr::drop_na(.data$Percent_Positivity) # Remove any NA values in Percent_Positivity - historic_data <- list(stacked_data = stacked_data, - line_data = line_data) - return(historic_data) + historic_dataset <- list(stacked_dataset = stacked_dataset, + line_dataset = line_dataset) + return(historic_dataset) } + + diff --git a/R/cleaning_data.R b/R/cleaning_data.R index af82d69..7f33614 100644 --- a/R/cleaning_data.R +++ b/R/cleaning_data.R @@ -156,38 +156,99 @@ clean_tosferina_data <- function(report_data) { return(report_data) } -#' @title Función para reemplazar espacios en los nombres de las columnas con -#' guiones bajos + + + + + + + + + + + + + + + + + + +#' @title Limpiar espacios en los nombres de las columnas +#' +#' @description +#' Reemplaza los espacios y caracteres especiales en los nombres de las columnas +#' por guiones bajos, asegurando una nomenclatura estandarizada. +#' +#' @param dataset Un dataset con nombres de columna a limpiar. +#' @return Un dataset con nombres de columna estandarizados. #' @export -clean_colnames_spaces <- function(df) { - colnames(df) <- epitrix::clean_labels(colnames(df)) - return(df) +clean_colnames_spaces <- function(dataset) { + colnames(dataset) <- epitrix::clean_labels(colnames(dataset)) + return(dataset) } -#' @title Función que remueve los sufijos +#' @title Eliminar sufijos numéricos en los nombres de las columnas +#' +#' @description +#' Remueve los sufijos numéricos en los nombres de las columnas que siguen el +#' formato `...1`, `...2`, `...3`, común en datos importados desde archivos CSV o Excel. +#' +#' @param dataset Un dataset con nombres de columna que pueden contener sufijos numéricos. +#' @return Un dataset con nombres de columna sin sufijos numéricos. #' @export -clean_colnames_suffixes <- function(df) { - colnames(df) <- gsub("\\.\\.\\.[0-9]+$", "", colnames(df)) - return(df) +clean_colnames_suffixes <- function(dataset) { + colnames(dataset) <- gsub("\\.\\.\\.[0-9]+$", "", colnames(dataset)) + return(dataset) } -#' @title Función que rellena los años + +#' @title Rellenar valores faltantes en una columna +#' +#' @description +#' Usa `tidyr::fill()` para rellenar los valores faltantes en la columna especificada, +#' propagando los valores hacia abajo. +#' +#' @param dataset Un dataset que contiene la columna a rellenar. +#' @param column_name Nombre de la columna a rellenar (como variable sin comillas). +#' @return Un dataset con los valores de la columna completados. #' @export -fill_down_year <- function(df, column_name) { - df <- df %>% +fill_down_column <- function(dataset, column_name) { + dataset <- dataset %>% tidyr::fill({{ column_name }}, .direction = "down") # Devolver el data frame limpio - return(df) + return(dataset) } -#' @title Función que limpia la información historica +#' @title Limpiar datos históricos epidemiológicos +#' +#' @description +#' Aplica varias transformaciones al dataset de datos históricos: +#' - Remueve sufijos en nombres de columnas (`clean_colnames_suffixes`). +#' - Estandariza los nombres de las columnas (`janitor::clean_names`). +#' - Rellena valores faltantes en las columnas `ano` y `periodo_epidemiologico` (`fill_down_column`). +#' +#' @param dataset Un dataset con datos históricos sin procesar. +#' @return Un dataset limpio y listo para análisis. #' @export -clean_historic_data <- function(tabla) { - tabla <- tabla %>% +clean_historic_data <- function(dataset) { + + #get texts of the axis from config.yml + config_path <- system.file("extdata", "config.yml", package = "labrep") + config_path <- "C:/Users/willi/GITHUB/labrep/inst/extdata/config.yml" + + year_column <- config::get(file = config_path,"respiratory_viruses_historic_data")$year + col_year <- year_column$col_name + periodo_epidemiologico <- config::get(file = config_path,"respiratory_viruses_historic_data")$periodo_epidemiologico + col_periodo <- periodo_epidemiologico$col_name + + dataset <- dataset %>% clean_colnames_suffixes() %>% - clean_colnames_spaces() %>% - fill_down_year("ano") %>% - slice(1:32) - return(tabla) + janitor::clean_names() %>% + fill_down_column(col_year) %>% + fill_down_column(col_periodo) + + return(dataset) + } diff --git a/R/import_data.R b/R/import_data.R index e42e132..b5167ed 100644 --- a/R/import_data.R +++ b/R/import_data.R @@ -29,9 +29,23 @@ import_data_viral_circulation <- function(report_data = NULL, return(viral_circulation_data) } -#' @title Obtener todas las tables de las bases historicas +#' @title Extraer todas las tablas de una hoja de Excel +#' +#' @description +#' Detecta y extrae múltiples tablas dentro de una hoja de Excel, identificando +#' separaciones mediante filas y columnas en blanco. +#' +#' @param file_name Ruta del archivo de Excel. +#' +#' @return Lista de dataframes, donde cada elemento representa una tabla identificada dentro de la hoja. #' @export -get_all_tables <- function(file_name, sheet_name) { +get_all_tables <- function(file_name) { + + config_path <- system.file("extdata", "config.yml", package = "labrep") + sheet_name <- config::get(file = config_path,"respiratory_viruses_historic_data")$excel_sheet_name + sheet_name <- sheet_name$value + + # Leer los datos de la hoja especificada en el archivo data <- readxl::read_excel(file_name, sheet = sheet_name) @@ -76,21 +90,34 @@ get_all_tables <- function(file_name, sheet_name) { return(tables) } -#' @title Extraer una tabla específica de la lista y devolverla como data.frame +#' @title Obtener una tabla específica de una lista de tablas +#' +#' @description +#' Extrae una tabla de una lista de tablas generada a partir de `get_all_tables`, +#' seleccionándola por su índice en la lista. +#' +#' @param list_of_tables Lista de tablas, donde cada elemento es un dataframe. +#' +#' @return Un dataframe correspondiente a la tabla seleccionada. #' @export -get_selected_table <- function(tables, INDICADOR) { +get_selected_table <- function(list_tables) { + + config_path <- system.file("extdata", "config.yml", package = "labrep") + indicator <- config::get(file = config_path,"respiratory_viruses_historic_data")$table_number + indicator <- indicator$value + # Verificar que 'tables' es una lista - if (!is.list(tables)) { + if (!is.list(list_tables)) { stop("El argumento 'tables' debe ser una lista de tablas.") } # Verificar que el INDICADOR es válido - if (INDICADOR < 1 || INDICADOR > length(tables)) { + if (indicator < 1 || indicator > length(list_tables)) { stop("El INDICADOR está fuera del rango de las tablas disponibles.") } # Extraer la tabla especificada - selected_table <- tables[[INDICADOR]] + selected_table <- list_tables[[indicator]] # Asegurarse de que la tabla es un data.frame o convertirla en uno si es necesario if (!is.data.frame(selected_table)) { diff --git a/R/plotting_data.R b/R/plotting_data.R index 9f61660..b96aaee 100644 --- a/R/plotting_data.R +++ b/R/plotting_data.R @@ -302,120 +302,130 @@ plot_table_epiweek_tosferina <- function(data_epiweek, return(table_epiweek) } -#' @title Graficar el tiempo epidemiológico historico + + +#' @title Generar gráfico de evolución epidemiológica histórica +#' +#' @description +#' Crea un gráfico combinado con barras apiladas y una línea de tendencia, +#' representando la evolución de virus respiratorios y la positividad epidemiológica +#' en función del tiempo. +#' +#' @param dataset_epiTime Dataset con datos epidemiológicos, que debe incluir las columnas +#' `ano`, `periodo_epidemiologico`, y los distintos tipos de virus. +#' @param periodo_epi Período epidemiológico a destacar en el gráfico (valor entre 1 y 13). +#' +#' @return Un objeto `ggplot2` con el gráfico de evolución epidemiológica. #' @export -plot_historic_epi_time <- function(stacked_data, tabla, - line_data) { - scaling_factor <- 700 / 70 - # Plot the figure +plot_historic_epi_time <- function(dataset_epi_time, periodo_epi ) { + + # Ensure the epidemiological period is within valid range + periodo_epi <- pmax(1, pmin(periodo_epi, 13)) + + #get stacked bars and line datasets + historic_epi_times <- get_historic_epi_times(dataset_epi_times = dataset_epi_time) + stacked_data <- historic_epi_times$stacked_data + line_data <- historic_epi_times$line_data + + #get texts of the axis from config.yml + config_path <- system.file("extdata", "config.yml", package = "labrep") + + text_axis_labels <- config::get(file = config_path,"respiratory_viruses_historic_data")$legends + y_axis1_name <- text_axis_labels$y_1_axis_name + x_axis_name <- text_axis_labels$x_axis_name + + #get plot theme parameters + colores <- get_color_periodo_epidemiologico() + plot_parameters <- get_axis_config_periodo_epidemiologico() + plot_text_years_labels <- get_text_labels_periodo_epidemiologico(dataset_epi_time=dataset_epi_time) + annotate_x_pos <- 0.6727 * periodo_epi + 17.8273 + + # Generate the plot ggplot2::ggplot() + # Stacked bar chart - ggplot2::geom_bar(data = stacked_data, - ggplot2::aes(x = YearWeek, y = Cases, fill = Virus_Type), - stat = "identity", - width = 0.4) + - - # Line chart for % positivity with scaling applied - ggplot2::geom_line(data = line_data, - ggplot2::aes(x = YearWeek, - y = Percent_Positivity * scaling_factor, - color = "Positivity Rate", - group = 1), - color = "#E97132", - linewidth = 0.7) + - - # Scale and labels with specified y-axis breaks - ggplot2::scale_y_continuous(name = "NÚMERO DE CASOS POSITIVOS", - limits = c(-500, 700), breaks = seq(0, 700, by = 100), - sec.axis = ggplot2::sec_axis(~ . / scaling_factor, - breaks = seq(0, 70, by = 10), - labels = function(x) sprintf("%.1f", x)) + ggplot2::geom_bar( + data = stacked_data, + ggplot2::aes(x = YearWeek, y = Cases, fill = Virus_Type), + stat = "identity", + width = plot_parameters$bar_width + ) + + # Line chart for positivity rate + ggplot2::geom_line( + data = line_data, + ggplot2::aes( + x = YearWeek, + y = Percent_Positivity * plot_parameters$scaling_factor, + group = 1 + ), + color = colores$color_linea, + linewidth = plot_parameters$line_width + ) + + # Y-axis and secondary axis + ggplot2::scale_y_continuous( + name = y_axis1_name, + limits = c(-500, plot_parameters$y_axis1_max_value), + breaks = seq(0, plot_parameters$y_axis1_max_value, by = 100), + sec.axis = ggplot2::sec_axis(~ . / plot_parameters$scaling_factor, + breaks = seq(0, plot_parameters$y_axis2_max_value, by = 10), + labels = scales::number_format(accuracy = 0.1)) ) + - ggplot2::scale_x_discrete(labels = tabla$periodo_epidemiologico)+ + # X-axis + ggplot2::scale_x_discrete(labels = dataset_epi_time$periodo_epidemiologico) + + # Custom fill colors ggplot2::scale_fill_manual(values = c( - "a_h1n1_pdm09" = "#8064A2", # Light blue for A(H1N1)pdm09 - "a_no_subtipificado" = "#4BACC6", # Purple for A no subtipificado - "a_h3" = "#F79646", # Green for A(H3) - "influenza_B" = "#2C4D75", # Dark gray for Influenza B - "adenovirus" = "#4D3B62", # Dark teal for Adenovirus - "metapneumovirus" = "#2C4D75", # Dark purple for Metapneumovirus - "rinovirus" = "#B65708", # Dark green for Rinovirus - "bocavirus" = "#729ACA", # Blue for Bocavirus - "otros_virus" = "#4F81BD", # Blue for Otros Virus - "parainfluenza" = "#772C2A", # Brown for Parainfluenza - "vsr" = "#5F7530", # Dark green for VSR - "nueva_columna" = "black" # Black for nueva_columna (appears as line in legend) + "a_h1n1_pdm09" = colores$color_a_h1n1_pdm09, + "a_no_subtipificado" = colores$color_a_no_subtipificado, + "a_h3" = colores$color_a_h3, + "influenza_b" = colores$color_influenza_b, + "parainfluenza" = colores$color_parainfluenza, + "vsr" = colores$color_vsr, + "adenovirus" = colores$color_adenovirus, + "metapneumovirus" = colores$color_metapneumovirus, + "rinovirus" = colores$color_rinovirus, + "bocavirus" = colores$color_bocavirus, + "otros_virus" = colores$color_otros_virus + ), + labels = c( + "a_h1n1_pdm09" = "H1N1 2009", + "a_no_subtipificado" = "A no subtipificado", + "a_h3" = "H3N2", + "influenza_b" = "Influenza B", + "parainfluenza" = "Parainfluenza", + "vsr" = "VSR", + "adenovirus" = "Adenovirus", + "metapneumovirus" = "Metapneumovirus", + "rinovirus" = "Rinovirus", + "bocavirus" = "Bocavirus", + "otros_virus" = "Otros Virus" )) + - ggplot2::labs(x = "PERÍODO EPIDEMIOLOGICO", fill = NULL, color = NULL) + - - # Customize the grid lines + ggplot2::labs(x = x_axis_name, fill = NULL, color = NULL) + + # Themes and styling ggplot2::theme_minimal() + ggplot2::theme( - axis.text.x = ggplot2::element_text(angle = 0, size = 7, - margin = ggplot2::margin(t = -255, b=-5)), - axis.title.x = ggplot2::element_text(margin = ggplot2::margin(t = 20, b=-10), - size = 8, face = "bold", - color = "#595959"), - axis.title.y = ggplot2::element_text(hjust = 0.75, size = 8, - face = "bold", color = "#595959"), - panel.grid.major.x = ggplot2::element_blank(), # Remove vertical major grid lines - panel.grid.minor.x = ggplot2::element_blank(), # Remove vertical minor grid lines + axis.text.x = ggplot2::element_text(size = 7, margin = ggplot2::margin(t = -255, b = -5)), + axis.title.x = ggplot2::element_text(margin = ggplot2::margin(t = 20, b = -10), size = 8, face = "bold", color = colores$color_axis_titles), + axis.title.y = ggplot2::element_text(hjust = 0.7,margin = ggplot2::margin(r = 10), + size = 8, face = "bold", color = colores$color_axis_titles), + panel.grid.major.x = ggplot2::element_blank(), + panel.grid.minor.x = ggplot2::element_blank(), panel.grid.minor.y = ggplot2::element_blank(), legend.position = "bottom", legend.key.size = ggplot2::unit(1.2, "lines"), legend.key.height = ggplot2::unit(0.02, "lines"), legend.text = ggplot2::element_text(size = 7) ) + - # Agregar líneas verticales con altura ajustable usando geom_segment - ggplot2::geom_segment(ggplot2::aes(x = 13.5, xend = 13.5, y = -25, yend = 700), - color = "black", linewidth = 0.65) + - ggplot2::geom_segment(ggplot2::aes(x = 26.5, xend = 26.5, y = -25, yend = 700), - color = "black", linewidth = 0.65) + - ggplot2::annotate("text", x = c(6, 19, 31), y = -35, label = c("2022", - "2023", - "2024"), - size = 2.4, fontface = "bold") + ggplot2::guides( fill = ggplot2::guide_legend( nrow = 3, byrow = TRUE ), - color = "none") + - ggplot2::annotate("segment", x = 21, xend = 22.2, y = -150, yend = -150, - color = "#E97132", linewidth = 0.7) + - ggplot2::annotate("text", x = 22.5, y = -150, label = "% DE POSITIVIDAD", - hjust = 0, color = "black", size = 2) -} - -#' @title Graficar la tabla de la leyenda -#' @export -plot_table_legend <- function(report_data, - include_sars = FALSE) { - report_data$cs <- "" - report_data <- report_data %>% - dplyr::arrange(.data$etiqueta) %>% - dplyr::relocate(.data$cs, .after = .data$etiqueta) - colors <- get_colors_age_groups(order = TRUE, - hex_cods = TRUE, - include_sars = include_sars) - col_names <- names(report_data) - table <- knitr::kable(report_data, - col.names = NULL, - align = "c", - longtable = TRUE) %>% - kableExtra::kable_styling( - full_width = FALSE, - position = "left", - latex_options = c("bordered", "hold_position"), - font_size = 9 - ) %>% - kableExtra::column_spec(2, background = colors) %>% - kableExtra::column_spec(1, border_left = TRUE) %>% - kableExtra::column_spec(length(col_names), border_right = TRUE) %>% - kableExtra::column_spec(column = seq(3, length(col_names)), - width = "1.6cm") %>% - kableExtra::column_spec(length(col_names), border_right = TRUE, - width = "1.7cm") - return(table) -} - + color = "none" + )+ + # Vertical lines and annotations + ggplot2::geom_segment(ggplot2::aes(x = 13.5, xend = 13.5, y = -25, yend = 700), color = colores$color_vertical_lines, linewidth = 0.65) + + ggplot2::geom_segment(ggplot2::aes(x = 26.5, xend = 26.5, y = -25, yend = 700), color = colores$color_vertical_lines, linewidth = 0.65) + + ggplot2::annotate("text", x = c(7, 20, 26.5 + floor(periodo_epi / 2)), y = -35, label = plot_text_years_labels, size = 2.4, fontface = "bold") + + ggplot2::annotate("segment", x = annotate_x_pos-0.3, xend = annotate_x_pos + 0.9, y = -145, yend = -145, color = colores$color_linea, linewidth = 0.7) + + ggplot2::annotate("text", x = annotate_x_pos + 1.3, y = -145, label = "% de positividad", hjust = 0, color = "black", size = 2.5) + +} \ No newline at end of file diff --git a/R/theme.R b/R/theme.R index e8f9ea6..3ddb07a 100644 --- a/R/theme.R +++ b/R/theme.R @@ -26,3 +26,78 @@ get_colors_age_groups <- function(order = FALSE, } return(colors) } + + + +#' @title Obtener configuración de colores para el periodo epidemiológico +#' +#' @description +#' Devuelve una lista con los colores asignados a diferentes elementos del gráfico, +#' incluyendo líneas, títulos de ejes, líneas verticales y tipos de virus. +#' +#' @return Lista con los colores definidos +#' @export +get_color_periodo_epidemiologico <- function() { + return(list( + color_linea = "#E97132", + color_axis_titles = "#595959", + color_vertical_lines = "black", + color_a_h1n1_pdm09 = "#8064A2", + color_a_no_subtipificado = "#4BACC6", + color_a_h3 = "#F79646", + color_influenza_b = "#2C4D75", + color_parainfluenza = "#772C2A", + color_vsr = "#5F7530", + color_adenovirus = "#4D3B62", + color_metapneumovirus = "#2C4D75", + color_rinovirus = "#B65708", + color_bocavirus = "#729ACA", + color_otros_virus = "#4F81BD" + )) +} + + +#' @title Obtener configuración de los ejes para el periodo epidemiológico +#' +#' @description +#' Devuelve una lista con los valores máximos de los ejes Y, el factor de escala +#' y los parámetros de ancho de barra y línea. +#' +#' @return Lista con la configuración de los ejes: +#' - `y_axis1_max_value`: Valor máximo del primer eje Y. +#' - `y_axis2_max_value`: Valor máximo del segundo eje Y. +#' - `scaling_factor`: Factor de escala entre los dos ejes. +#' - `bar_width`: Ancho de las barras. +#' - `line_width`: Ancho de la línea. +#' @export +get_axis_config_periodo_epidemiologico <- function() { + return(list( + y_axis1_max_value = 700, + y_axis2_max_value = 70, + scaling_factor = 700 / 70, + bar_width = 0.4, + line_width = 0.7 + )) +} + + + +#' @title Generar etiquetas de texto para los periodos epidemiológicos +#' +#' @description +#' Extrae los años únicos del dataset y genera etiquetas en formato "AÑO ". +#' +#' @param dataset_epiTime Dataset con una columna `ano` que contiene los años. +#' @return Vector de texto con etiquetas para cada año. +#' @export +get_text_labels_periodo_epidemiologico <- function(dataset_epi_time) { + + # Extract unique years from the dataset + unique_years <- sort(unique(dataset_epi_time$ano)) + + # Generate the annotation text dynamically + annotation_text <- paste("AÑO", unique_years) + + return(annotation_text) +} + diff --git a/inst/extdata/config.yml b/inst/extdata/config.yml index 88b1a15..dfa6098 100644 --- a/inst/extdata/config.yml +++ b/inst/extdata/config.yml @@ -44,6 +44,19 @@ default: cols_clean: ["interpretacion_de_resultados"] gender: col_valid: "genero" + respiratory_viruses_historic_data: + legends: + x_axis_name: "PERÍODO EPIDEMIOLÓGICO" + y_1_axis_name: "NÚMERO DE CASOS POSITIVOS" + year: + col_name: "ano" + periodo_epidemiologico: + col_name: "periodo_epidemiologico" + excel_sheet_name: + value: "POR PERIODO" + table_number: + value: 2 + viruses: - name: "influenza_a" filmarray: diff --git a/inst/rmarkdown/templates/reports/skeleton/skeleton.Rmd b/inst/rmarkdown/templates/reports/skeleton/skeleton.Rmd index d10b74a..5453368 100644 --- a/inst/rmarkdown/templates/reports/skeleton/skeleton.Rmd +++ b/inst/rmarkdown/templates/reports/skeleton/skeleton.Rmd @@ -49,11 +49,16 @@ params: label: "Semana epidemiológica" input: text value: 23 + periodo_epi: + label: "Periodo epidemiológica" + input: numeric + value: 5 editor_options: markdown: wrap: 72 --- + ```{r setup, echo=FALSE, include=FALSE} knitr::opts_chunk$set( echo = FALSE, @@ -79,6 +84,8 @@ print(params$fci_data) \includepdf[pages={1}]{cover.pdf} + + ```{=tex} \begin{center} {\color{colortitles} Alcalde Mayor de Bogotá\\} @@ -153,7 +160,6 @@ www.saludcapital.gov.co\\} current_year <- format(Sys.Date(), "%Y") ``` - Durante `r current_year`, el Laboratorio de Salud Pública (LSP) continúa apoyando la vigilancia de la infección respiratoria aguda en Bogotá, mediante el procesamiento de muestras remitidas por instituciones centinela de los @@ -168,23 +174,43 @@ cadena de la polimerasa con transcriptasa inversa (RT-PCR) para el diagnóstico de los principales agentes a los que se les atribuye el IRAG. -```{r historic-data} -SHEET_NAME <- "POR PERIODO" -INDICADOR <- 2 -tables <- get_all_tables(params$historic_data, SHEET_NAME) -tabla <- get_selected_table(tables, INDICADOR) -tabla <- clean_historic_data(tabla = tabla) -historic_epi_times <- get_historic_epi_times(tabla = tabla) + + +```{r dataset_respiratory_viruses_2022_20224} +#IMPORTING DATASET: "VIRUS RESPIRATORIO 2022 A 2024.xlsx" + +all_tables_from_sheet <- get_all_tables(file_name=params$historic_data) + +dataset_periodo_epi <- get_selected_table(list_tables=all_tables_from_sheet) +``` + +```{r cl_dataset_respiratory_viruses_last_3_years} +# CLEANING +# cl = clean +cl_dataset_periodo_epi <- clean_historic_data(dataset = dataset_periodo_epi) + + ``` +```{r filtered_dataset_respiratory_viruses_years} +# PROCESSING +# pr = processed + +pr_dataset_respiratory_viruses_last_3_years <- cl_dataset_periodo_epi %>% + filter((cl_dataset_periodo_epi$ano == 2024 & periodo_epidemiologico <= params$periodo_epi) | cl_dataset_periodo_epi$ano != 2024) + +``` + + En el análisis del comportamiento de los virus respiratorios por periodo epidemiológico desde el 2022 se observa que se ha mantenido la circulación de virus como Rinovirus, Adenovirus y VSR. Para los tres años entre los periodos 3 al 6 coincide con el pico respiratorio que se presenta en todos los años (Figura 1). ```{r plot-historic-data, include=TRUE, fig.height=6, fig.width=8,fig.cap="Circulación de virus respiratorios por período epidemiológico Año 2022 - 2024, Laboratorio de Salud Pública Bogotá."} -plot_historic_epi_time(stacked_data = historic_epi_times$stacked_data, - line_data = historic_epi_times$line_data, - tabla = tabla) +#PLOTTING Figura 1 + +plot_historic_epi_time(dataset = pr_dataset_respiratory_viruses_last_3_years ,periodo_epi= params$periodo_epi) ``` + ```{r filmarray-data} filmarray_data <- import_data_viral_circulation(report_data = params$fci_data, sheet = 1, diff --git a/inst/rmarkdown/templates/reports/skeleton/skeleton.aux b/inst/rmarkdown/templates/reports/skeleton/skeleton.aux new file mode 100644 index 0000000..4a64cdc --- /dev/null +++ b/inst/rmarkdown/templates/reports/skeleton/skeleton.aux @@ -0,0 +1,12 @@ +\relax +\providecommand \babel@aux [2]{\global \let \babel@toc \@gobbletwo } +\@nameuse{bbl@beforestart} +\providecommand\hyper@newdestlabel[2]{} +\providecommand\HyField@AuxAddToFields[1]{} +\providecommand\HyField@AuxAddToCoFields[2]{} +\providecommand\BKM@entry[2]{} +\babel@aux{spanish}{} +\BKM@entry{id=1,dest={73656374696F6E2E31},srcline={161}}{5C3337365C3337375C303030565C303030695C303030725C303030755C303030735C3030305C3034305C303030725C303030655C303030735C303030705C303030695C303030725C303030615C303030745C3030306F5C303030725C303030695C3030306F5C30303073} +\@writefile{toc}{\contentsline {section}{\numberline {1}Virus respiratorios}{2}{section.1}\protected@file@percent } +\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces Circulación de virus respiratorios por período epidemiológico Año 2022 - 2024, Laboratorio de Salud Pública Bogotá.}}{2}{figure.caption.1}\protected@file@percent } +\gdef \@abspage@last{4} diff --git a/inst/rmarkdown/templates/reports/skeleton/skeleton.pdf b/inst/rmarkdown/templates/reports/skeleton/skeleton.pdf new file mode 100644 index 0000000..30f1bb8 Binary files /dev/null and b/inst/rmarkdown/templates/reports/skeleton/skeleton.pdf differ diff --git a/labrep.Rproj b/labrep.Rproj index 21a4da0..aa5790d 100644 --- a/labrep.Rproj +++ b/labrep.Rproj @@ -1,4 +1,5 @@ Version: 1.0 +ProjectId: d2ce4c2f-5d32-4b32-a575-47b0b418771c RestoreWorkspace: Default SaveWorkspace: Default