From 8cbd97ad0b3578f0d5ee477e92e419e657fbb9a5 Mon Sep 17 00:00:00 2001 From: Thomas OBADIA <thomas.obadia@pasteur.fr> Date: Thu, 17 Oct 2024 15:30:19 +0200 Subject: [PATCH] Include censusid instead of record_id in the list consisting of all participants whom data were collected during the inventory phase. Also fix an issue where age category would not be derived fromperly since database was dumped and processed with labels instead of code for categorical data. And as always, a few typos... --- ...NTORY_02_list_all_inventory_participants.R | 28 ++++++++++--------- .../INVENTORY_03_list_all_inventory_houses.R | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/01_INVENTORY/INVENTORY_02_list_all_inventory_participants.R b/01_INVENTORY/INVENTORY_02_list_all_inventory_participants.R index 3cd117c..6b5b17a 100644 --- a/01_INVENTORY/INVENTORY_02_list_all_inventory_participants.R +++ b/01_INVENTORY/INVENTORY_02_list_all_inventory_participants.R @@ -17,7 +17,7 @@ ### SOURCE THE DATABASE ###################################################################### if (!exists("DATA_EXTRACT_IS_RECENT_INV") || !DATA_EXTRACT_IS_RECENT_INV) { - cat("Database is outdated and will be dumped again.\n") + cat("INVENTORY Database is outdated and will be dumped again.\n") source("./01_INVENTORY/INVENTORY_01_dump_REDCap_database.R") } @@ -52,6 +52,8 @@ inventory_list_p <- dat_inventory_raw %>% values_transform = as.character) %>% pivot_wider(names_from = "pivot_variable", values_from = "value") %>% + rename(censusid = id) %>% + mutate(agey = as.numeric(agey)) %>% extract(pivot_hh_n, into = c("nested_hhid"), @@ -63,24 +65,24 @@ inventory_list_p <- dat_inventory_raw %>% # Add age as a categorical variable # Madagascar: proposition of structure by Mirana # Ethiopîa : identical as above by Thomas - mutate(agey_cat = case_when(country == "M" & agey < 1 ~ "y00_01", - country == "M" & agey >= 1 & agey <= 5 ~ "y01_05", - country == "M" & agey > 5 & agey <= 13 ~ "y05_13", - country == "M" & agey > 13 & agey <= 24 ~ "y13_24", - country == "M" & agey > 24 ~ "y24_inf", - country == "E" & agey < 1 ~ "y00_01", - country == "E" & agey >= 1 & agey <= 5 ~ "y01_05", - country == "E" & agey > 5 & agey <= 13 ~ "y05_13", - country == "E" & agey > 13 & agey <= 24 ~ "y13_24", - country == "E" & agey > 24 ~ "y24_inf")) %>% + mutate(agey_cat = case_when(country %in% c("M", "Madagascar") & agey < 1 ~ "y00_01", + country %in% c("M", "Madagascar") & agey >= 1 & agey <= 5 ~ "y01_05", + country %in% c("M", "Madagascar") & agey > 5 & agey <= 13 ~ "y05_13", + country %in% c("M", "Madagascar") & agey > 13 & agey <= 24 ~ "y13_24", + country %in% c("M", "Madagascar") & agey > 24 ~ "y24_inf", + country %in% c("E", "Ethiopia") & agey < 1 ~ "y00_01", + country %in% c("E", "Ethiopia") & agey >= 1 & agey <= 5 ~ "y01_05", + country %in% c("E", "Ethiopia") & agey > 5 & agey <= 13 ~ "y05_13", + country %in% c("E", "Ethiopia") & agey > 13 & agey <= 24 ~ "y13_24", + country %in% c("E", "Ethiopia") & agey > 24 ~ "y24_inf")) %>% # Discard rows for whom no data was filled, i.e. empty placeholders in REDCap filter(!is.na(sex) & !is.na(agey)) %>% # Retain only columns of interest for derived data (list of everyone in inventory) select( - # REDCap internal record_id - record_id, + # CensusID is the individual-level identifier as record_id does not make sense anymore + censusid, # Items used to derive the house-and-household ID country, clusterid, hid, nested_hhid, nested_subjid, diff --git a/01_INVENTORY/INVENTORY_03_list_all_inventory_houses.R b/01_INVENTORY/INVENTORY_03_list_all_inventory_houses.R index ae71f68..7748b7e 100644 --- a/01_INVENTORY/INVENTORY_03_list_all_inventory_houses.R +++ b/01_INVENTORY/INVENTORY_03_list_all_inventory_houses.R @@ -16,7 +16,7 @@ ### SOURCE THE DATABASE ###################################################################### if (!exists("DATA_EXTRACT_IS_RECENT_INV") || !DATA_EXTRACT_IS_RECENT_INV) { - cat("Database is outdated and will be dumped again.\n") + cat("INVENTORY Database is outdated and will be dumped again.\n") source("./01_INVENTORY/INVENTORY_01_dump_REDCap_database.R") } -- GitLab