View source: R/derive_param_exist_flag.R
derive_param_exist_flag | R Documentation |
Add a new parameter indicating that a certain event exists in a dataset.
AVALC
and AVAL
indicate if an event occurred or not. For example, the
function can derive a parameter indicating if there is measurable disease at
baseline.
derive_param_exist_flag(
dataset = NULL,
dataset_ref,
dataset_add,
condition,
true_value = "Y",
false_value = NA_character_,
missing_value = NA_character_,
filter_add = NULL,
by_vars = get_admiral_option("subject_keys"),
set_values_to
)
dataset |
Input dataset The variables specified by the |
dataset_ref |
Reference dataset, e.g., ADSL The variables specified in |
dataset_add |
Additional dataset The variables specified by the This dataset is used to check if an event occurred or not. Any observation
in the dataset fulfilling the event condition ( |
condition |
Event condition The condition is evaluated at the additional dataset ( For all groups where it evaluates as For all groups where it evaluates as For all groups not present in the additional dataset |
true_value |
True value For all groups with at least one observations in the additional dataset
( Default: Permitted Value: A character scalar |
false_value |
False value For all groups with at least one observations in the additional dataset
( Default: Permitted Value: A character scalar |
missing_value |
Values used for missing information For all groups without an observation in the additional dataset
( Default: Permitted Value: A character scalar |
filter_add |
Filter for additional data Only observations fulfilling the specified condition are taken into account for flagging. If the parameter is not specified, all observations are considered. Permitted Values: a condition |
by_vars |
Grouping variables Permitted Values: list of variables created by |
set_values_to |
Variables to set A named list returned by |
The additional dataset (dataset_add
) is restricted to the observations
matching the filter_add
condition.
For each group in dataset_ref
a new observation is created.
The AVALC
variable is added and set to the true value (true_value
)
if for the group at least one observation exists in the (restricted)
additional dataset where the condition evaluates to TRUE
.
It is set to the false value (false_value
) if for the group at least
one observation exists and for all observations the condition evaluates
to FALSE
or NA
.
Otherwise, it is set to the missing value (missing_value
), i.e., for
those groups not in dataset_add
.
The variables specified by the set_values_to
parameter are added to
the new observations.
The new observations are added to input dataset.
The input dataset with a new parameter indicating if an event
occurred (AVALC
and the variables specified by by_vars
and set_value_to
are populated for the new parameter).
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_exposure()
,
derive_param_framingham()
,
derive_param_map()
,
derive_param_qtc()
,
derive_param_rr()
,
derive_param_wbc_abs()
,
derive_summary_records()
library(tibble)
library(dplyr, warn.conflicts = FALSE)
library(lubridate)
# Derive a new parameter for measurable disease at baseline
adsl <- tribble(
~USUBJID,
"1",
"2",
"3"
) %>%
mutate(STUDYID = "XX1234")
tu <- tribble(
~USUBJID, ~VISIT, ~TUSTRESC,
"1", "SCREENING", "TARGET",
"1", "WEEK 1", "TARGET",
"1", "WEEK 5", "TARGET",
"1", "WEEK 9", "NON-TARGET",
"2", "SCREENING", "NON-TARGET",
"2", "SCREENING", "NON-TARGET"
) %>%
mutate(
STUDYID = "XX1234",
TUTESTCD = "TUMIDENT"
)
derive_param_exist_flag(
dataset_ref = adsl,
dataset_add = tu,
filter_add = TUTESTCD == "TUMIDENT" & VISIT == "SCREENING",
condition = TUSTRESC == "TARGET",
false_value = "N",
missing_value = "N",
set_values_to = exprs(
AVAL = yn_to_numeric(AVALC),
PARAMCD = "MDIS",
PARAM = "Measurable Disease at Baseline"
)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.