Skip to content
Snippets Groups Projects
Commit 8cbd97ad authored by Thomas  OBADIA's avatar Thomas OBADIA :speech_balloon:
Browse files

Include censusid instead of record_id in the list consisting of all...

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...
parent 67b5beed
No related branches found
No related tags found
No related merge requests found
......@@ -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,
......
......@@ -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")
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment