Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/derive_vars_disposition_reason.R
Deprecated, please use derive_vars_disposition_reason()
instead.
Derive a disposition reason from the the relevant records in the disposition domain.
1 2 3 4 5 6 7 8 9 10 11 | derive_disposition_reason(
dataset,
dataset_ds,
new_var,
reason_var,
new_var_spe = NULL,
reason_var_spe = NULL,
format_new_vars = format_reason_default,
filter_ds,
subject_keys = vars(STUDYID, USUBJID)
)
|
dataset |
Input dataset. |
dataset_ds |
Dataset containing the disposition information (e.g.: It must contain:
|
new_var |
Name of the disposition reason variable. A variable name is expected (e.g. |
reason_var |
The variable used to derive the disposition reason A variable name is expected (e.g. |
new_var_spe |
Name of the disposition reason detail variable. A variable name is expected (e.g. Default: NULL |
reason_var_spe |
The variable used to derive the disposition reason detail A variable name is expected (e.g. Default: NULL |
format_new_vars |
The function used to derive the reason(s) This function is used to derive the disposition reason(s) and must follow the below conventions
Default: format_reason_default defined as:
format_reason_default <- function(reason, reason_spe = NULL)
out <- if ( is.null(reason_spe) ) reason else reason_spe
if_else ( reason != "COMPLETED" & !is.na(reason), out, NA_character_)
format_reason_default(DSDECOD) returns |
filter_ds |
Filter condition for the disposition data. Filter used to select the relevant disposition data.
It is expected that the filter restricts Permitted Values: logical expression. |
subject_keys |
Variables to uniquely identify a subject A list of quosures where the expressions are symbols as returned by
|
This functions returns the main reason for discontinuation (e.g. DCSREAS
or DCTREAS
).
The reason for discontinuation is derived based on reason_var
(e.g. DSDECOD
) and
format_new_vars
.
If new_var_spe
is not NULL, then the function will also return the details associated
with the reason for discontinuation (e.g. DCSREASP
).
The details associated with the reason for discontinuation are derived based on
reason_var_spe
(e.g. DSTERM
), reason_var
and format_new_vars
.
the input dataset with the disposition reason(s) (new_var
and
if required new_var_spe
) added.
Samia Kabi
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 | library(dplyr, warn.conflicts = FALSE)
library(admiral.test)
data("dm")
data("ds")
# Derive DCSREAS using the default format
dm %>%
derive_disposition_reason(
dataset_ds = ds,
new_var = DCSREAS,
reason_var = DSDECOD,
filter_ds = DSCAT == "DISPOSITION EVENT"
) %>%
select(STUDYID, USUBJID, DCSREAS)
# Derive DCSREAS and DCSREASP using a study-specific format
format_dcsreas <- function(x, y = NULL) {
out <- if (is.null(y)) x else y
case_when(
!(x %in% c("COMPLETED", "SCREEN FAILURE")) & !is.na(x) ~ out,
TRUE ~ NA_character_
)
}
dm %>%
derive_disposition_reason(
dataset_ds = ds,
new_var = DCSREAS,
reason_var = DSDECOD,
new_var_spe = DCSREASP,
reason_var_spe = DSTERM,
format_new_vars = format_dcsreas,
filter_ds = DSCAT == "DISPOSITION EVENT"
) %>%
select(STUDYID, USUBJID, DCSREAS, DCSREASP)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.