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

Closes #39: CoEQ test data #45

Merged
merged 11 commits into from
Nov 5, 2024
74 changes: 43 additions & 31 deletions data-raw/qs_metabolic.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

library(tibble)
library(dplyr)
library(pharmaversesdtm)
library(purrr)
library(stringr)

# Set seed for random data generation ----
Expand All @@ -23,28 +21,28 @@ vs_metabolic <- admiralmetabolic::vs_metabolic

# Set up questions, codes and categories ----
coeq_structure <- tibble::tribble(
~QSCAT, ~QSSCAT, ~QSTESTCD, ~QSTEST,
"COEQ", "EATING", "COEQ01", "How hungry have you felt?",
"COEQ", "EATING", "COEQ02", "How full have you felt?",
"COEQ", "EATING", "COEQ03", "How strong was your desire to eat sweet foods?",
"COEQ", "EATING", "COEQ04", "How strong was your desire to eat savoury foods?",
"COEQ", "EMOTIONS", "COEQ05", "How happy have you felt?",
"COEQ", "EMOTIONS", "COEQ06", "How anxious have you felt?",
"COEQ", "EMOTIONS", "COEQ07", "How alert have you felt?",
"COEQ", "EMOTIONS", "COEQ08", "How contented have you felt?",
"COEQ", "GENERAL CRAVINGS", "COEQ09", "During the last 7 days how often have you had food cravings?",
"COEQ", "GENERAL CRAVINGS", "COEQ10", "How strong have any food cravings been?",
"COEQ", "GENERAL CRAVINGS", "COEQ11", "How difficult has it been to resist any food cravings?",
"COEQ", "GENERAL CRAVINGS", "COEQ12", "How often have you eaten in response to food cravings?",
"COEQ", "GENERAL CRAVINGS", "COEQ13", "Chocolate or chocolate flavoured foods",
"COEQ", "SPECIFIC CRAVINGS", "COEQ14", "Other sweet foods (cakes, pastries, biscuits, etc)",
"COEQ", "SPECIFIC CRAVINGS", "COEQ15", "Fruit or fruit juice",
"COEQ", "SPECIFIC CRAVINGS", "COEQ16", "Dairy foods (cheese, yoghurts, milk, etc)",
"COEQ", "SPECIFIC CRAVINGS", "COEQ17", "Starchy foods (bread, rice, pasta, etc)",
"COEQ", "SPECIFIC CRAVINGS", "COEQ18", "Savoury foods (french fries, crisps, burgers, pizza, etc)",
"COEQ", "CONTROL EATING", "COEQ19", "Generally, how difficult has it been to control your eating?",
"COEQ", "CONTROL EATING", "COEQ20", "Which one food makes it most difficult for you to control eating?",
"COEQ", "CONTROL EATING", "COEQ21", "How difficult has it been to resist eating this food during the last 7 days?",
~QSCAT, ~QSTESTCD, ~QSTEST,
"COEQ", "COEQ01", "How hungry have you felt?",
"COEQ", "COEQ02", "How full have you felt?",
"COEQ", "COEQ03", "How strong was your desire to eat sweet foods?",
"COEQ", "COEQ04", "How strong was your desire to eat savoury foods?",
"COEQ", "COEQ05", "How happy have you felt?",
"COEQ", "COEQ06", "How anxious have you felt?",
"COEQ", "COEQ07", "How alert have you felt?",
"COEQ", "COEQ08", "How contented have you felt?",
"COEQ", "COEQ09", "During the last 7 days how often have you had food cravings?",
"COEQ", "COEQ10", "How strong have any food cravings been?",
"COEQ", "COEQ11", "How difficult has it been to resist any food cravings?",
"COEQ", "COEQ12", "How often have you eaten in response to food cravings?",
"COEQ", "COEQ13", "Chocolate or chocolate flavoured foods",
"COEQ", "COEQ14", "Other sweet foods (cakes, pastries, biscuits, etc)",
"COEQ", "COEQ15", "Fruit or fruit juice",
"COEQ", "COEQ16", "Dairy foods (cheese, yoghurts, milk, etc)",
"COEQ", "COEQ17", "Starchy foods (bread, rice, pasta, etc)",
"COEQ", "COEQ18", "Savoury foods (french fries, crisps, burgers, pizza, etc)",
"COEQ", "COEQ19", "Generally, how difficult has it been to control your eating?",
"COEQ", "COEQ20", "Which one food makes it most difficult for you to control eating?",
"COEQ", "COEQ21", "How difficult has it been to resist eating this food during the last 7 days?",
)

# Use visit schedule and days from VS ----
Expand All @@ -62,19 +60,34 @@ qs_metabolic_shell <- visit_schedule %>%
qs_metabolic_results <- qs_metabolic_shell %>%
mutate(
DOMAIN = "QS",
QSORRES = round(runif(n(), min = 0, max = 100)),
QSORRESU = "cm",
QSSTRESU = "cm",
QSSTRESN = QSORRES,
QSSTRESC = as.character(QSORRES),
QSORRES = as.character(round(runif(n(), min = 0, max = 100))),
QSORRESU = "mm",
QSSTRESU = "mm",
QSSTRESN = as.numeric(QSORRES),
QSSTRESC = QSORRES,
QSBLFL = if_else(VISIT == "BASELINE", "Y", NA_character_)
) %>%
# Update the free text question (COEQ20)
mutate(
QSSTRESC = case_when(
QSTESTCD == "COEQ20" & QSSTRESN < 33 ~ "Ice Cream",
QSTESTCD == "COEQ20" & QSSTRESN < 66 ~ "Pizza",
manciniedoardo marked this conversation as resolved.
Show resolved Hide resolved
QSTESTCD == "COEQ20" ~ "Pasta",
TRUE ~ QSSTRESC
)
) %>%
mutate(
QSSTRESN = if_else(QSTESTCD == "COEQ20", NA, QSSTRESN),
QSORRES = if_else(QSTESTCD == "COEQ20", QSSTRESC, QSORRES),
QSORRESU = if_else(QSTESTCD == "COEQ20", NA_character_, QSORRESU),
QSSTRESU = if_else(QSTESTCD == "COEQ20", NA_character_, QSSTRESU),
)

# Order variables, sort and add sequence number ----
qs_metabolic_seq <- qs_metabolic_results %>%
select(
STUDYID, USUBJID, DOMAIN, VISIT, VISITNUM, VISITDY, QSBLFL, QSDTC, QSDY,
QSCAT, QSSCAT, QSTEST, QSTESTCD, QSORRES, QSORRESU, QSSTRESC, QSSTRESN, QSSTRESU
QSCAT, QSTEST, QSTESTCD, QSORRES, QSORRESU, QSSTRESC, QSSTRESN, QSSTRESU
) %>%
arrange(STUDYID, USUBJID, VISITNUM, QSTESTCD) %>%
group_by(USUBJID) %>%
Expand All @@ -86,7 +99,6 @@ labels <- list(
DOMAIN = "Domain Abbreviation",
QSBLFL = "Baseline Flag",
QSCAT = "Category for Questionnaire",
QSSCAT = "Subcategory for Questionnaire",
QSTEST = "Questionnaire Test Name",
QSTESTCD = "Questionnaire Test Short Name",
QSORRES = "Result or Finding in Original Units",
Expand Down
Binary file modified data/qs_metabolic.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion man/qs_metabolic.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading