This function is deprecated, please use derive_var_joined_exist_flag()
instead.
Usage
derive_var_confirmation_flag(
dataset,
by_vars,
order,
new_var,
tmp_obs_nr_var = NULL,
join_vars,
join_type,
first_cond = NULL,
filter,
true_value = "Y",
false_value = NA_character_,
check_type = "warning"
)
Arguments
- dataset
Input dataset
The variables specified by the
by_vars
andjoin_vars
parameter are expected.- by_vars
By variables
The specified variables are used as by variables for joining the input dataset with itself.
- order
Order
The observations are ordered by the specified order.
- new_var
New variable
The specified variable is added to the input dataset.
- tmp_obs_nr_var
Temporary observation number
The specified variable is added to the input dataset and set to the observation number with respect to
order
. For each by group (by_vars
) the observation number starts with1
. The variable can be used in the conditions (filter
,first_cond
). It is not included in the output dataset. It can be used to flag consecutive observations or the last observation (see last example below).- join_vars
Variables to keep from joined dataset
The variables needed from the other observations should be specified for this parameter. The specified variables are added to the joined dataset with suffix ".join". For example to flag all observations with
AVALC == "Y"
andAVALC == "Y"
for at least one subsequent visitjoin_vars = exprs(AVALC, AVISITN)
andfilter = AVALC == "Y" & AVALC.join == "Y" & AVISITN < AVISITN.join
could be specified.The
*.join
variables are not included in the output dataset.- join_type
Observations to keep after joining
The argument determines which of the joined observations are kept with respect to the original observation. For example, if
join_type = "after"
is specified all observations after the original observations are kept.For example for confirmed response or BOR in the oncology setting or confirmed deterioration in questionnaires the confirmatory assessment must be after the assessment to be flagged. Thus
join_type = "after"
could be used.Whereas, sometimes you might allow for confirmatory observations to occur prior to the observation to be flagged. For example, to flag AEs occurring on or after seven days before a COVID AE. Thus
join_type = "all"
could be used.Permitted Values:
"before"
,"after"
,"all"
- first_cond
Condition for selecting range of data
If this argument is specified, the other observations are restricted up to the first observation where the specified condition is fulfilled. If the condition is not fulfilled for any of the other observations, no observations are considered, i.e., the observation is not flagged.
This parameter should be specified if
filter
contains summary functions which should not apply to all observations but only up to the confirmation assessment. For an example see the third example below.- filter
Condition for selecting observations
The filter is applied to the joined dataset for flagging the confirmed observations. The condition can include summary functions. The joined dataset is grouped by the original observations. I.e., the summary function are applied to all observations up to the confirmation observation. For example,
filter = AVALC == "CR" & all(AVALC.join %in% c("CR", "NE")) & count_vals(var = AVALC.join, val = "NE") <= 1
selects observations with response "CR" and for all observations up to the confirmation observation the response is "CR" or "NE" and there is at most one "NE".- true_value
Value of
new_var
for flagged observationsDefault:
"Y"
- false_value
Value of
new_var
for observations not flaggedDefault:
NA_character_
- check_type
Check uniqueness?
If
"warning"
or"error"
is specified, the specified message is issued if the observations of the input dataset are not unique with respect to the by variables and the order.Default:
"warning"
Permitted Values:
"none"
,"warning"
,"error"
Details
The following steps are performed to produce the output dataset.
Step 1
The input dataset is joined with itself by the variables specified for
by_vars
. From the right hand side of the join only the variables
specified for join_vars
are kept. The suffix ".join" is added to these
variables.
For example, for by_vars = USUBJID
, join_vars = exprs(AVISITN, AVALC)
and input dataset
# A tibble: 2 x 4
USUBJID AVISITN AVALC AVAL
<chr> <dbl> <chr> <dbl>
1 1 Y 1
1 2 N 0
the joined dataset is
A tibble: 4 x 6
USUBJID AVISITN AVALC AVAL AVISITN.join AVALC.join
<chr> <dbl> <chr> <dbl> <dbl> <chr>
1 1 Y 1 1 Y
1 1 Y 1 2 N
1 2 N 0 1 Y
1 2 N 0 2 N
Step 2
The joined dataset is restricted to observations with respect to
join_type
and order
.
The dataset from the example in the previous step with join_type = "after"
and order = exprs(AVISITN)
is restricted to
A tibble: 4 x 6
USUBJID AVISITN AVALC AVAL AVISITN.join AVALC.join
<chr> <dbl> <chr> <dbl> <dbl> <chr>
1 1 Y 1 2 N
Step 3
If first_cond
is specified, for each observation of the input dataset the
joined dataset is restricted to observations up to the first observation
where first_cond
is fulfilled (the observation fulfilling the condition
is included). If for an observation of the input dataset the condition is
not fulfilled, the observation is removed.
See also
Other deprecated:
derive_var_disposition_status()
,
derive_var_worst_flag()
,
derive_vars_disposition_reason()
,
format_eoxxstt_default()
,
format_reason_default()