View source: R/derive_expected_records.R
derive_expected_records | R Documentation |
Add expected records as new observations for each 'by group' when the dataset contains missing observations.
derive_expected_records(
dataset,
dataset_ref,
by_vars = NULL,
set_values_to = NULL
)
dataset |
Input dataset The variables specified by the |
dataset_ref |
Expected observations dataset Data frame with the expected observations, e.g., all the expected
combinations of |
by_vars |
Grouping variables For each group defined by Permitted Values: list of variables created by |
set_values_to |
Variables to be set The specified variables are set to the specified values for the new observations. A list of variable name-value pairs is expected.
|
For each group (the variables specified in the by_vars
parameter),
those records from dataset_ref
that are missing in the input
dataset are added to the output dataset.
The input dataset with the missed expected observations added for each
by_vars
. Note, a variable will only be populated in the new parameter rows
if it is specified in by_vars
or set_values_to
.
BDS-Findings Functions for adding Parameters/Records:
default_qtc_paramcd()
,
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()
library(tibble)
adqs <- tribble(
~USUBJID, ~PARAMCD, ~AVISITN, ~AVISIT, ~AVAL,
"1", "a", 1, "WEEK 1", 10,
"1", "b", 1, "WEEK 1", 11,
"2", "a", 2, "WEEK 2", 12,
"2", "b", 2, "WEEK 2", 14
)
# Example 1. visit variables are parameter independent
parm_visit_ref <- tribble(
~AVISITN, ~AVISIT,
1, "WEEK 1",
2, "WEEK 2"
)
derive_expected_records(
dataset = adqs,
dataset_ref = parm_visit_ref,
by_vars = exprs(USUBJID, PARAMCD),
set_values_to = exprs(DTYPE = "DERIVED")
)
# Example 2. visit variables are parameter dependent
parm_visit_ref <- tribble(
~PARAMCD, ~AVISITN, ~AVISIT,
"a", 1, "WEEK 1",
"a", 2, "WEEK 2",
"b", 1, "WEEK 1"
)
derive_expected_records(
dataset = adqs,
dataset_ref = parm_visit_ref,
by_vars = exprs(USUBJID, PARAMCD),
set_values_to = exprs(DTYPE = "DERIVED")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.