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

Refactor loading of R environment content (global variables and functions) so...

Refactor loading of R environment content (global variables and functions) so that all environment from 00_COMMON is always sourced and available in other projects.
parent daa55d5a
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,15 @@ require(ggthemes)
######################################################################
### CUSTOM R ENVIRONMENT & FUNCTIONS
######################################################################
source("./00_COMMON/COMMON_00_R_functions.R")
######################################################################
### RUN TEST CODE
######################################################################
......@@ -48,7 +57,7 @@ PVSTATEM_STUDY_TITLE <- "PvSTATEM"
######################################################################
### PARTICIPANT IDENTIFIER
### PARTICIPANT & SAMPLE IDENTIFIERS
######################################################################
## Global variable storing country codes (named vector)
# - E: Ethiopia
......@@ -71,21 +80,6 @@ PVSTATEM_TIMEPOINT <- c("Observational" = "OB",
"Evaluation round 2" = "D",
"Passive Case Detection" = "PCD")
## Global variable storing sample type codes (named vector)
PVSTATEM_SAMPLE_TYPE_CODE <- c("Case Report Form" = "CRF",
"Patient Information Sheet" = "PIS",
"Sampling Sheet" = "SAS",
"G6PD results" = "G6P",
"Heparin tube" = "HEP",
"EDTA" = "EDT",
"Dried Blood Spot" = "DBS",
"Bloodsmear" = "BLS",
"Rapid Diagnostic Test" = "RDT",
"Serum" = "SER",
"Red Blood Cell pellet" = "RBC",
"Cryo stabilat" = "CRY",
"Additional spare" = "SPA")
## Global variable storing the possible values for aliquot number (vector)
PVSTATEM_ALIQUOT_RANGE <- 1:3
......@@ -95,17 +89,31 @@ PVSTATEM_LABELS_PER_ROW <- 7
PVSTATEM_LABELS_PER_COL <- 17
PVSTATEM_LABELS_PER_SHEET <- PVSTATEM_LABELS_PER_ROW * PVSTATEM_LABELS_PER_COL
######################################################################
### RANDOMIZATION LIST
######################################################################
## Global variables storing cluster randomization list
PVSTATEM_RANDOMIZATION_E <- NULL
PVSTATEM_RANDOMIZATION_M <- read.table(file = "./00_COMMON/resources/randomisation.csv",
header = TRUE,
dec = ".",
sep = ",") %>%
select(-X) %>%
rename(cluster = cluster.ID) %>%
mutate(cluster = gsub(pattern = "M",
mutate(country = "M",
cluster = gsub(pattern = "M",
replacement = "",
x = cluster)) %>%
mutate(cluster = sprintf(cluster, fmt = "%02s")) %>%
mutate(n_enroll_max = case_when(randomisation == 0 ~ 255,
randomisation == 1 ~ ceiling(size * 1.10),
.default = NA))
PVSTATEM_RANDOMIZATION <- PVSTATEM_RANDOMIZATION_E %>%
bind_rows(PVSTATEM_RANDOMIZATION_M)
......@@ -28,9 +28,9 @@ require(ggmap) # More general set of methods
######################################################################
### CUSTOM R FUNCTIONS
### CUSTOM R ENVIRONMENT & FUNCTIONS
######################################################################
source("./00_COMMON/COMMON_00_R_functions.R")
source("./00_COMMON/COMMON_00_R_environment.R")
source("./01_INVENTORY/INVENTORY_00_R_functions.R")
......
......@@ -30,7 +30,7 @@ require(tidyverse) # Data manipulation made easy
######################################################################
### CUSTOM R FUNCTIONS
######################################################################
source("./00_COMMON/COMMON_00_R_functions.R")
source("./00_COMMON/COMMON_00_R_environment.R")
......
......@@ -30,7 +30,7 @@ require(tidyverse) # Data manipulation made easy
######################################################################
### CUSTOM R FUNCTIONS
######################################################################
source("./00_COMMON/COMMON_00_R_functions.R")
source("./00_COMMON/COMMON_00_R_environment.R")
source("./03_INTERVENTIONAL_M0/INTERVENTIONAL_M0_00_R_functions.R")
......@@ -109,3 +109,84 @@ CURATE_DATA_RECALCULATE_AGEY_MADAGASCAR <- FALSE
######################################################################
### REDCAP LABELLING
######################################################################
## Depending on casting functions, results from redcapAPI::exportRecordsTyped()
## may be label-based or raw codes, whever a coding mechanism is involved.
## The following global variables will store both codes and labels to be used as
## a dictionary when checking if a coded data matches an expected category
# Global variable: labeling of country for Ethiopia
REDCAP_LABELS_RADIO_COUNTRY_E <- c("Ethiopia",
"Ethiopie",
"E")
# Global variable: labeling of country for Madagascar
REDCAP_LABELS_RADIO_COUNTRY_E <- c("Madagascar",
"Madagasikara",
"M")
# Global variable: labeling of 'Yes' categorical value
REDCAP_LABELS_RADIO_YES <- c(1,
"Yes",
"Oui",
"Eny")
# Global variable: labeling of 'No' categorical value
REDCAP_LABELS_RADIO_NO <- c(0,
"No",
"Non",
"Tsia")
# Global variable: labeling of 1/0/0 in Pf/pan RDTs
REDCAP_LABELS_RADIO_RDT_PF_PAN_100 <- c("RDT_M_100",
"100 (Negative)",
"100")
# Global variable: labeling of 1/1/0 in Pf/pan RDTs
REDCAP_LABELS_RADIO_RDT_PF_PAN_110 <- c("RDT_M_110",
"110 (Non-falciparum)",
"110")
# Global variable: labeling of 1/0/1 in Pf/pan RDTs
REDCAP_LABELS_RADIO_RDT_PF_PAN_101 <- c("RDT_M_101",
"101 (P. falciparum)",
"101")
# Global variable: labeling of 1/1/1 in Pf/pan RDTs
REDCAP_LABELS_RADIO_RDT_PF_PAN_111 <- c("RDT_M_111",
"111 (P. falciparum or mixed)",
"111")
# Global variable: labeling of 1/0/0 in Pf/Pv RDTs
REDCAP_LABELS_RADIO_RDT_PF_PV_100 <- c("RDT_E_100",
"100 (Negative)",
"100",
"Mihiba")
# Global variable: labeling of 1/1/0 in Pf/Pv RDTs
REDCAP_LABELS_RADIO_RDT_PF_PV_110 <- c("RDT_E_110",
"110 (P. vivax)",
"110",
"P. vivax")
# Global variable: labeling of 1/0/1 in Pf/Pv RDTs
REDCAP_LABELS_RADIO_RDT_PF_PV_101 <- c("RDT_E_101",
"101 (P. falciparum)",
"101",
"P. falciparum")
# Global variable: labeling of 1/1/1 in Pf/Pv RDTs
REDCAP_LABELS_RADIO_RDT_PF_PV_111 <- c("RDT_E_111",
"111 (Mixed)",
"111",
"Mixed")
# Global variable: labeling of 'Checked' checkboxes
REDCAP_LABELS_CHECKBOX_CHECKED <- c("Checked",
"1")
# Global variable: labeling of 'Unchecked' checkboxes
REDCAP_LABELS_CHECKBOX_UNCHECKED <- c("Unchecked",
"0")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment