View source: R/derive_vars_event_flag.R
derive_vars_event_flag | R Documentation |
Creates two flag variables for the event occurred, one for the event occurred within each by group and one to flag if the event occurred or not for each day.
derive_vars_event_flag(
dataset,
by_vars,
aval_cutoff,
new_var1 = NULL,
new_var2 = NULL
)
dataset |
Input dataset The variables specified by the |
by_vars |
Grouping variables The variables to be considered for grouping for creating a new
variable |
aval_cutoff |
Cutoff value for For |
new_var1 |
Name of the new flag variable 1 A new flag variable will be created with values `Y` or `N`. If the event is occurred at least once during a observation period for a subject then the new variable will be flagged as `Y` otherwise `N`. |
new_var2 |
Name of the new flag variable 2. A new flag variable will be created with values `Y` or `N`. If the event is occurred on the particular day then the new variable will be flagged as `Y` otherwise `N`. |
The event is considered to have occurred if AVAL
is greater than the aval_cutoff
or AVALC
has values Y
, MILD
, MODERATE
, SEVERE
. In all other cases, the
event is not considered to have occurred.
The names for the new flag variables created will be sponsor specific.
For the new_var1
it will flag all observations as "Y" within the by group
if the event occurred at least once during observation period. If the event
is not at all occurred during the observation period then all the
observations within by group will be flagged as "N".
For derived maximum records in FATESTCD
, the new_var2
will be
set to NA
.
If both new_var1
and new_var2
are NULL
, this function will return the
input dataset as output dataset.
The dataset with the flag variables added to it.
Other der_var:
derive_var_aval_adis()
,
derive_vars_crit()
,
derive_vars_max_flag()
,
derive_vars_merged_vaccine()
,
derive_vars_params()
,
derive_vars_vaxdt()
library(tibble)
library(admiral)
library(dplyr)
input <- tribble(
~USUBJID, ~FAOBJ, ~ATPTREF, ~AVAL, ~AVALC, ~FATEST, ~FATESTCD, ~FASCAT,
"1", "REDNESS", "VAC1", 3.5, "3.5", "Diameter", "DIAMETER", "ADMIN-SITE",
"1", "REDNESS", "VAC1", 4.5, "4.5", "Diameter", "DIAMETER", "ADMIN-SITE",
"1", "REDNESS", "VAC1", 1.5, "1.5", "Diameter", "DIAMETER", "ADMIN-SITE",
"1", "REDNESS", "VAC1", 4.5, "4.5", "Diameter", "DIAMETER", "ADMIN-SITE",
"1", "FATIGUE", "VAC1", 1, "MILD", "Severity", "SEV", "SYSTEMIC",
"1", "FATIGUE", "VAC1", 2, "MODERATE", "Severity", "SEV", "SYSTEMIC",
"1", "FATIGUE", "VAC1", 0, "NONE", "Severity", "SEV", "SYSTEMIC",
"1", "FATIGUE", "VAC1", 2, "MODERATE", "Severity", "SEV", "SYSTEMIC",
"1", "REDNESS", "VAC2", 6.5, "6.5", "Diameter", "DIAMETER", "ADMIN-SITE",
"1", "REDNESS", "VAC2", 7.5, "7.5", "Diameter", "DIAMETER", "ADMIN-SITE",
"1", "REDNESS", "VAC2", 2.5, "2.5", "Diameter", "DIAMETER", "ADMIN-SITE",
"1", "REDNESS", "VAC2", 7.5, "7.5", "Diameter", "DIAMETER", "ADMIN-SITE",
"1", "FATIGUE", "VAC2", 1, "MILD", "Severity", "SEV", "SYSTEMIC",
"1", "FATIGUE", "VAC2", 2, "MODERATE", "Severity", "SEV", "SYSTEMIC",
"1", "FATIGUE", "VAC2", 0, "NONE", "Severity", "SEV", "SYSTEMIC",
"1", "FATIGUE", "VAC2", 2, "MODERATE", "Severity", "SEV", "SYSTEMIC",
)
derive_vars_event_flag(
dataset = input,
by_vars = exprs(USUBJID, FAOBJ, ATPTREF),
aval_cutoff = 2.5,
new_var1 = EVENTL,
new_var2 = EVENTDL
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.