Baseline Type BASETYPE is needed when there is more than one definition of
baseline for a given Analysis Parameter PARAM in the same dataset. For a
given parameter, if Baseline Value BASE or BASEC are derived and there
is more than one definition of baseline, then BASETYPE must be non-null on
all records of any type for that parameter where either BASE or BASEC
are also non-null. Each value of BASETYPE refers to a definition of
baseline that characterizes the value of BASE on that row. Please see
section 4.2.1.6 of the ADaM Implementation Guide, version 1.3 for further
background.
Arguments
- dataset
-
Input dataset
The variables specified by the
basetypesargument are expected to be in the dataset.- Default value
none
- basetypes
-
A named list of expressions created using the
rlang::exprs()functionThe names corresponds to the values of the newly created
BASETYPEvariables and the expressions are used to subset the input dataset.- Default value
none
Details
Adds the BASETYPE variable to a dataset and duplicates records based upon
the provided conditions.
For each element of basetypes the input dataset is subset based upon
the provided expression and the BASETYPE variable is set to the name of the
expression. Then, all subsets are stacked. Records which do not match any
condition are kept and BASETYPE is set to NA.
See also
BDS-Findings Functions for adding Parameters/Records:
default_qtc_paramcd(),
derive_expected_records(),
derive_extreme_event(),
derive_extreme_records(),
derive_locf_records(),
derive_param_bmi(),
derive_param_bsa(),
derive_param_computed(),
derive_param_doseint(),
derive_param_exist_flag(),
derive_param_exposure(),
derive_param_framingham(),
derive_param_map(),
derive_param_qtc(),
derive_param_rr(),
derive_param_wbc_abs(),
derive_summary_records()
Examples
Add records for different baseline types (basetypes)
The basetypes argument is a named list of expressions where each name
becomes a value of BASETYPE and each expression defines which records
receive that value. A record can match multiple expressions and will be
duplicated once for each matching BASETYPE. In this example, records for
subject P01 show the duplication across both baseline types.
Records that do not match any condition in basetypes are kept in the
output dataset with BASETYPE set to NA. In this example, SCREENING
records do not match any of the basetypes conditions and are therefore
retained with BASETYPE = NA.
library(tibble)
library(dplyr, warn.conflicts = FALSE)
bds <- tribble(
~USUBJID, ~EPOCH, ~PARAMCD, ~ASEQ, ~AVAL,
"P01", "SCREENING", "PARAM01", 1, 10.2,
"P01", "RUN-IN", "PARAM01", 2, 10.0,
"P01", "RUN-IN", "PARAM01", 3, 9.8,
"P01", "DOUBLE-BLIND", "PARAM01", 4, 9.2,
"P01", "DOUBLE-BLIND", "PARAM01", 5, 10.1,
"P02", "SCREENING", "PARAM01", 1, 12.2,
"P02", "RUN-IN", "PARAM01", 2, 12.1,
"P02", "DOUBLE-BLIND", "PARAM01", 3, 10.2
)
derive_basetype_records(
dataset = bds,
basetypes = exprs(
"RUN-IN" = EPOCH %in% c("RUN-IN", "DOUBLE-BLIND"),
"DOUBLE-BLIND" = EPOCH == "DOUBLE-BLIND"
)
)
#> # A tibble: 11 × 6
#> USUBJID EPOCH PARAMCD ASEQ AVAL BASETYPE
#> <chr> <chr> <chr> <dbl> <dbl> <chr>
#> 1 P01 SCREENING PARAM01 1 10.2 <NA>
#> 2 P02 SCREENING PARAM01 1 12.2 <NA>
#> 3 P01 RUN-IN PARAM01 2 10 RUN-IN
#> 4 P01 RUN-IN PARAM01 3 9.8 RUN-IN
#> 5 P01 DOUBLE-BLIND PARAM01 4 9.2 RUN-IN
#> 6 P01 DOUBLE-BLIND PARAM01 5 10.1 RUN-IN
#> 7 P02 RUN-IN PARAM01 2 12.1 RUN-IN
#> 8 P02 DOUBLE-BLIND PARAM01 3 10.2 RUN-IN
#> 9 P01 DOUBLE-BLIND PARAM01 4 9.2 DOUBLE-BLIND
#> 10 P01 DOUBLE-BLIND PARAM01 5 10.1 DOUBLE-BLIND
#> 11 P02 DOUBLE-BLIND PARAM01 3 10.2 DOUBLE-BLIND
Include all records for multiple baseline type derivations (basetypes = TRUE)
When all parameter records need to be included for multiple baseline
type derivations (such as "LAST" and "WORST"), set each expression in
basetypes to TRUE. This duplicates every record once for each named
baseline type.
bds <- tribble(
~USUBJID, ~EPOCH, ~PARAMCD, ~ASEQ, ~AVAL,
"P01", "RUN-IN", "PARAM01", 1, 10.0,
"P01", "RUN-IN", "PARAM01", 2, 9.8,
"P01", "DOUBLE-BLIND", "PARAM01", 3, 9.2,
"P01", "DOUBLE-BLIND", "PARAM01", 4, 10.1
)
derive_basetype_records(
dataset = bds,
basetypes = exprs(
"LAST" = TRUE,
"WORST" = TRUE
)
)
#> # A tibble: 8 × 6
#> USUBJID EPOCH PARAMCD ASEQ AVAL BASETYPE
#> <chr> <chr> <chr> <dbl> <dbl> <chr>
#> 1 P01 RUN-IN PARAM01 1 10 LAST
#> 2 P01 RUN-IN PARAM01 2 9.8 LAST
#> 3 P01 DOUBLE-BLIND PARAM01 3 9.2 LAST
#> 4 P01 DOUBLE-BLIND PARAM01 4 10.1 LAST
#> 5 P01 RUN-IN PARAM01 1 10 WORST
#> 6 P01 RUN-IN PARAM01 2 9.8 WORST
#> 7 P01 DOUBLE-BLIND PARAM01 3 9.2 WORST
#> 8 P01 DOUBLE-BLIND PARAM01 4 10.1 WORST
