
Default Format for the Disposition Reason
Source:R/derive_vars_disposition_reason.R
format_reason_default.RdDefine a function to map the disposition reason, to be used as a parameter in
derive_vars_disposition_reason().
Arguments
- reason
the disposition variable used for the mapping (e.g.
DSDECOD).- reason_spe
the disposition variable used for the mapping of the details if required (e.g.
DSTERM).
Details
format_reason_default(DSDECOD) returns DSDECOD when DSDECOD is not 'COMPLETED' nor NA.
format_reason_default(DSDECOD, DSTERM) returns DSTERM when DSDECOD is
equal to 'OTHER'.
Usually this function can not be used with %>%.
See also
derive_vars_disposition_reason()
Utilities for Formatting Observations:
convert_blanks_to_na(),
convert_na_to_blanks(),
format_eoxxstt_default(),
yn_to_numeric()
Examples
library(dplyr, warn.conflicts = FALSE)
library(admiral.test)
data("admiral_dm")
data("admiral_ds")
# Derive DCSREAS using format_reason_default
admiral_dm %>%
derive_vars_disposition_reason(
dataset_ds = admiral_ds,
new_var = DCSREAS,
reason_var = DSDECOD,
format_new_vars = format_reason_default,
filter_ds = DSCAT == "DISPOSITION EVENT"
) %>%
select(STUDYID, USUBJID, DCSREAS)
#> # A tibble: 306 x 3
#> STUDYID USUBJID DCSREAS
#> <chr> <chr> <chr>
#> 1 CDISCPILOT01 01-701-1015 NA
#> 2 CDISCPILOT01 01-701-1023 ADVERSE EVENT
#> 3 CDISCPILOT01 01-701-1028 NA
#> 4 CDISCPILOT01 01-701-1033 STUDY TERMINATED BY SPONSOR
#> 5 CDISCPILOT01 01-701-1034 NA
#> 6 CDISCPILOT01 01-701-1047 ADVERSE EVENT
#> 7 CDISCPILOT01 01-701-1057 SCREEN FAILURE
#> 8 CDISCPILOT01 01-701-1097 NA
#> 9 CDISCPILOT01 01-701-1111 ADVERSE EVENT
#> 10 CDISCPILOT01 01-701-1115 ADVERSE EVENT
#> # … with 296 more rows