Derive Criterion Flag Variables CRITy
, CRITyFL
, and CRITyFLN
Source: R/derive_vars_crit_flag.R
derive_vars_crit_flag.Rd
The function derives ADaM compliant criterion flags, e.g., to facilitate subgroup analyses.
If a criterion flag can't be derived with this function, the derivation is not ADaM compliant. It helps to ensure that
the condition of the criterion depends only on variables of the same row,
the
CRITyFL
is populated with valid values, i.e, either"Y"
andNA
or"Y"
,"N"
, andNA
,the
CRITy
variable is populated correctly, i.e.,set to a constant value within a parameter if
CRITyFL
is populated with"Y"
,"N"
, andNA
andset to a constant value within a parameter if the criterion condition is fulfilled and to
NA
otherwise ifCRITyFL
is populated with"Y"
, andNA
Usage
derive_vars_crit_flag(
dataset,
crit_nr = 1,
condition,
description,
values_yn = FALSE,
create_numeric_flag = FALSE
)
Arguments
- dataset
Input dataset
- crit_nr
The criterion number, i.e., the
y
inCRITy
Permitted Values: a positive integer
- condition
Condition for flagging records
See description of the
values_yn
argument for details on how theCRITyFL
variable is populated.Permitted Values: an unquoted expression which evaluates to a logical (in
dataset
)- description
The description of the criterion
The
CRITy
variable is set to the specified value.An expression can be specified to set the value depending on the parameter. Please note that the value must be constant within a parameter.
Permitted Values: an unquoted expression which evaluates to a character (in
dataset
)- values_yn
Should
"Y"
and"N"
be used forCRITyFL
?If set to
TRUE
, theCRITyFL
variable is set to"Y"
if the condition (condition
) evaluates toTRUE
, it is set to"N"
if the condition evaluate toFALSE
, and toNA
if it evaluates toNA
.Otherwise, the
CRITyFL
variable is set to"Y"
if the condition (condition
) evaluates toTRUE
, and toNA
otherwise.Permitted Values:
TRUE
,FALSE
- create_numeric_flag
Create a numeric flag?
If set to
TRUE
, theCRITyFLN
variable is created. It is set to1
ifCRITyFL == "Y"
, it set to0
ifCRITyFL == "N"
, and toNA
otherwise.Permitted Values:
TRUE
,FALSE
See also
BDS-Findings Functions that returns variable appended to dataset:
derive_basetype_records()
,
derive_var_analysis_ratio()
,
derive_var_anrind()
,
derive_var_atoxgr()
,
derive_var_atoxgr_dir()
,
derive_var_base()
,
derive_var_chg()
,
derive_var_ontrtfl()
,
derive_var_pchg()
,
derive_var_shift()
Examples
library(tibble)
adbds <- tribble(
~PARAMCD, ~AVAL,
"AST", 42,
"AST", 52,
"AST", NA_real_,
"ALT", 33,
"ALT", 51
)
# Create a criterion flag with values "Y" and NA
derive_vars_crit_flag(
adbds,
condition = AVAL > 50,
description = "Absolute value > 50"
)
#> # A tibble: 5 × 4
#> PARAMCD AVAL CRIT1FL CRIT1
#> <chr> <dbl> <chr> <chr>
#> 1 AST 42 NA NA
#> 2 AST 52 Y Absolute value > 50
#> 3 AST NA NA NA
#> 4 ALT 33 NA NA
#> 5 ALT 51 Y Absolute value > 50
# Create criterion flag with values "Y", "N", and NA and parameter dependent
# criterion description
derive_vars_crit_flag(
adbds,
crit_nr = 2,
condition = AVAL > 50,
description = paste(PARAMCD, "> 50"),
values_yn = TRUE,
create_numeric_flag = TRUE
)
#> # A tibble: 5 × 5
#> PARAMCD AVAL CRIT2FL CRIT2 CRIT2FLN
#> <chr> <dbl> <chr> <chr> <dbl>
#> 1 AST 42 N AST > 50 0
#> 2 AST 52 Y AST > 50 1
#> 3 AST NA NA AST > 50 NA
#> 4 ALT 33 N ALT > 50 0
#> 5 ALT 51 Y ALT > 50 1