View source: R/derive_study_day.R
derive_study_day | R Documentation |
derive_study_day
performs study day calculationThis function takes the an input data frame and a reference data frame (which is DM domain in most cases), and calculate the study day from reference date and target date. In case of unexpected conditions like reference date is not unique for each patient, or reference and input dates are not actual dates, NA will be returned for those records.
derive_study_day(
sdtm_in,
dm_domain,
tgdt,
refdt,
study_day_var,
merge_key = "USUBJID"
)
sdtm_in |
Input data frame that contains the target date. |
dm_domain |
Reference date frame that contains the reference date. |
tgdt |
Target date from |
refdt |
Reference date from |
study_day_var |
New study day variable name in the output. For example, AESTDY for AE domain and CMSTDY for CM domain. |
merge_key |
Character to represent the merging key between |
Data frame that takes all columns from sdtm_in
and a new variable
to represent the calculated study day.
ae <- data.frame(
USUBJID = c("study123-123", "study123-124", "study123-125"),
AESTDTC = c("2012-01-01", "2012-04-14", "2012-04-14")
)
dm <- data.frame(
USUBJID = c("study123-123", "study123-124", "study123-125"),
RFSTDTC = c("2012-02-01", "2012-04-14", NA)
)
ae$AESTDTC <- as.Date(ae$AESTDTC)
dm$RFSTDTC <- as.Date(dm$RFSTDTC)
derive_study_day(ae, dm, "AESTDTC", "RFSTDTC", "AESTDY")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.