diff --git a/01_INVENTORY/INVENTORY_02_list_all_inventory_participants.R b/01_INVENTORY/INVENTORY_02_list_all_inventory_participants.R index 3cd117c3f5ee48c30b665f8075f30e841162a9dc..6b5b17a7b24c3ad60acaca5217527001f17d1c8f 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 ae71f682c974dfcde8f735d1b9127a8e7a2363b5..7748b7ef618492fb3cab37509cf574316a9763d8 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") }