Description Usage Arguments Details Value Author(s) Examples
View source: R/derive_last_dose.R
Deprecated, please use derive_var_last_dose_date()
instead.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
dataset |
Input dataset. |
dataset_ex |
Input EX dataset. |
filter_ex |
Filtering condition applied to EX dataset. For example, it can be used to filter for valid dose. Defaults to NULL. |
by_vars |
Variables to join by (created by |
dose_start |
The dose start date variable. |
dose_end |
The dose end date variable. |
analysis_date |
The analysis date variable. |
dataset_seq_var |
The sequence variable
(this together with |
new_var |
The output variable. |
output_datetime |
Logical. Should only date or date-time variable be returned?
Defaults to |
check_dates_only |
Logical.
An assumption that start and end dates of treatment match is checked.
By default ( |
traceability_vars |
A named list returned by |
All date (date-time) variables can be characters in standard ISO format or
of date / date-time class.
For ISO format, see impute_dtc
- parameter dtc
for further details.
Date-time imputations are done as follows:
dose_end
: no date imputation, time imputation to 00:00:00
if time is missing.
analysis_date
: no date imputation, time imputation to 23:59:59
if time is missing.
The last dose date is derived as follows:
The dataset_ex
is filtered using filter_ex
, if provided.
This is useful for, for example, filtering for valid dose only.
The datasets dataset
and dataset_ex
are joined using by_vars
.
The last dose date is derived:
the last dose date is the maximum date where dose_end
is lower to or equal to
analysis_date
, subject to both date values are non-NA.
The last dose date is derived per by_vars
and dataset_seq_var
.
The last dose date is appended to the dataset
and returned to the user.
Furthermore, the following assumption is checked: start and end dates (datetimes) need to match.
Use check_dates_only
to control whether only dates or whole date-times need to be equal.
Input dataset with additional column new_var
.
Ondrej Slama
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | library(dplyr, warn.conflicts = FALSE)
library(admiral.test)
data(ae)
data(ex_single)
ae %>%
head(100) %>%
derive_last_dose(
head(ex_single, 100),
filter_ex = (EXDOSE > 0 | (EXDOSE == 0 & grepl("PLACEBO", EXTRT))) &
nchar(EXENDTC) >= 10,
dose_start = EXSTDTC,
dose_end = EXENDTC,
analysis_date = AESTDTC,
dataset_seq_var = AESEQ,
new_var = LDOSEDTM,
output_datetime = TRUE,
check_dates_only = FALSE
) %>%
select(STUDYID, USUBJID, AESEQ, AESTDTC, LDOSEDTM)
# or with traceability variables
ae %>%
head(100) %>%
derive_last_dose(
head(ex_single, 100),
filter_ex = (EXDOSE > 0 | (EXDOSE == 0 & grepl("PLACEBO", EXTRT))) &
nchar(EXENDTC) >= 10,
dose_start = EXSTDTC,
dose_end = EXENDTC,
analysis_date = AESTDTC,
dataset_seq_var = AESEQ,
new_var = LDOSEDTM,
output_datetime = TRUE,
check_dates_only = FALSE,
traceability_vars = dplyr::vars(LDOSEDOM = "EX", LDOSESEQ = EXSEQ, LDOSEVAR = "EXSTDTC")
) %>%
select(STUDYID, USUBJID, AESEQ, AESTDTC, LDOSEDTM, LDOSEDOM, LDOSESEQ, LDOSEVAR)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.