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

Calculate incidence by event #108

Closed
GeraldineGomez opened this issue Feb 23, 2024 · 2 comments · Fixed by #136
Closed

Calculate incidence by event #108

GeraldineGomez opened this issue Feb 23, 2024 · 2 comments · Fixed by #136
Assignees
Labels
enhancement New feature or request

Comments

@GeraldineGomez
Copy link
Member

No description provided.

@zmcucunuba
Copy link
Member

Hola, les dejo el código para descargar los datos de DANE con proyecciones 2005-2035:

#POBLACIÓN 2005 - 2035 COLOMBIA
#FEB 2024

library(httr)
library(readxl)
library(tidyverse)
library(dplyr)
library(tidyr)

rm(list=ls())

#años 2005 - 2019
url <- "https://www.dane.gov.co/files/censo2018/proyecciones-de-poblacion/Municipal/DCD-area-sexo-edad-proypoblacion-Mun-2005-2019.xlsx"
response <- GET(url)
temp_file <- tempfile(fileext = ".xlsx")
writeBin(content(response, "raw"), temp_file)
dat_05_19 <- read_excel(temp_file, skip = 11)
dat_05_19 <- sivirep::limpiar_encabezado(dat_05_19)

dat_05_19 <- dat_05_19 %>%
  pivot_longer(
    cols = starts_with("hombres_") | starts_with("mujeres_") | starts_with("total_"),
    names_to = c(".value", "grupo_edad"),
    names_pattern = "(.*)_(\\d+_y_mas|\\d+)$"
  ) %>%
  select(dp, dpnom, dpmp, mpio, ano, area_geografica, grupo_edad, hombres, mujeres, total) %>%
  mutate(grupo_edad = recode(grupo_edad, `85_y_mas` = "85+"))
dat_05_19 <- dat_05_19 %>% filter(!is.na(grupo_edad))


#Años 2020 - 2035
url2 <- "https://www.dane.gov.co/files/censo2018/proyecciones-de-poblacion/Municipal/DCD-area-sexo-edad-proypoblacion-Mun-2020-2035-ActPostCOVID-19.xlsx"
response2 <- GET(url2)
temp_file2 <- tempfile(fileext = ".xlsx")
writeBin(content(response2, "raw"), temp_file2)
dat_20_35 <- read_excel(temp_file2, skip = 8)
dat_20_35 <- sivirep::limpiar_encabezado(dat_20_35)

dat_20_35 <- dat_20_35 %>% rename(total_general= total)
dat_20_35 <- dat_20_35 %>%
  pivot_longer(
    cols = starts_with("hombres_") | starts_with("mujeres_") | starts_with("total_"),
    names_to = c(".value", "grupo_edad"),
    names_pattern = "(.*)_(\\d+_y_mas|\\d+)$"
  ) %>%
  select(dp, dpnom, dpmp, mpio, ano, area_geografica, grupo_edad, hombres, mujeres, total) %>%
  mutate(grupo_edad = recode(grupo_edad, `85_y_mas` = "85+"))
dat_20_35 <- dat_20_35 %>% filter(!is.na(grupo_edad))


dat_05_35 <- rbind(dat_05_19, dat_20_35)
saveRDS(dat_05_35, "data/dist_pob/Pop_DANE_2005-2035.RDS")

GeraldineGomez added a commit that referenced this issue Apr 19, 2024
…ation projections

A new function has been created to import the data incidence or the population projections from DANE and its corresponding documentation.

Ref: #108
GeraldineGomez added a commit that referenced this issue Apr 19, 2024
…rojections

A new function has been created to clean the data incidence or the population projections from DANE and its corresponding documentation.

Ref: #108
GeraldineGomez added a commit that referenced this issue Apr 19, 2024
… or mpio

A new function has been created to calculate the incidence by Colombia, department or municipality and its corresponding documentation.

Ref: #108
GeraldineGomez added a commit that referenced this issue Apr 19, 2024
…ts and municipalities

A new function has been created to calculate the incidence for all departments of Colombia,  or all municipalities of a department and its corresponding documentation.

Ref: #108
GeraldineGomez added a commit that referenced this issue Apr 23, 2024
GeraldineGomez added a commit that referenced this issue Apr 23, 2024
GeraldineGomez added a commit that referenced this issue Apr 23, 2024
GeraldineGomez added a commit that referenced this issue Apr 23, 2024
GeraldineGomez added a commit that referenced this issue Apr 23, 2024
GeraldineGomez added a commit that referenced this issue Apr 23, 2024
GeraldineGomez added a commit that referenced this issue Apr 23, 2024
…eir values

A new internal function has been created called obtener_dpto_mpio and its corresponding documentation to refactoring the department and municipality validation and gets their values.

Ref: #108
GeraldineGomez added a commit that referenced this issue Apr 23, 2024
…event

A new function has been created called obtener_cond_inciden_event and its corresponding documentation to simplify getting the conditions to calculate the incidence by event.

Ref: #108
GeraldineGomez added a commit that referenced this issue Apr 24, 2024
GeraldineGomez added a commit that referenced this issue Apr 24, 2024
GeraldineGomez added a commit that referenced this issue Apr 24, 2024
GeraldineGomez added a commit that referenced this issue Apr 24, 2024
GeraldineGomez added a commit that referenced this issue Apr 24, 2024
…and apply str_to_title to nombre_evento column

Ref: #108
GeraldineGomez added a commit that referenced this issue Apr 25, 2024
GeraldineGomez added a commit that referenced this issue Apr 25, 2024
GeraldineGomez added a commit that referenced this issue Apr 25, 2024
GeraldineGomez added a commit that referenced this issue Apr 25, 2024
GeraldineGomez added a commit that referenced this issue Apr 25, 2024
GeraldineGomez added a commit that referenced this issue Apr 25, 2024
@GeraldineGomez
Copy link
Member Author

In PR #138, PR #142, and PR #143, introduced incidence calculation functionality, enabling it by Colombia, departments, municipalities, and sex.

Moreover, plot functions like plot_map and plot_sex have been updated to include both incidence and case data in visualizations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants