View source: R/derive_merged.R
derive_vars_merged_lookup | R Documentation |
Merge user-defined lookup table with the input dataset. Optionally print a list of records from the input dataset that do not have corresponding mapping from the lookup table.
derive_vars_merged_lookup(
dataset,
dataset_add,
by_vars,
order = NULL,
new_vars = NULL,
mode = NULL,
filter_add = NULL,
check_type = "warning",
duplicate_msg = NULL,
print_not_mapped = TRUE
)
dataset |
Input dataset The variables specified by the |
dataset_add |
Lookup table The variables specified by the |
by_vars |
Grouping variables The input dataset and the selected observations from the additional dataset are merged by the specified variables. Variables can be renamed by naming the element, i.e.
Permitted Values: list of variables created by |
order |
Sort order If the argument is set to a non-null value, for each by group the first or last observation from the additional dataset is selected with respect to the specified order. Variables defined by the For handling of Permitted Values: list of expressions created by |
new_vars |
Variables to add The specified variables from the additional dataset are added to the output
dataset. Variables can be renamed by naming the element, i.e., For example And Values of the added variables can be modified by specifying an expression.
For example, If the argument is not specified or set to Permitted Values: list of variables or named expressions created by |
mode |
Selection mode Determines if the first or last observation is selected. If the If the Permitted Values: |
filter_add |
Filter for additional dataset ( Only observations fulfilling the specified condition are taken into account for merging. If the argument is not specified, all observations are considered. Variables defined by the Permitted Values: a condition |
check_type |
Check uniqueness? If If the Permitted Values: |
duplicate_msg |
Message of unique check If the uniqueness check fails, the specified message is displayed. Default: paste( "Dataset {.arg dataset_add} contains duplicate records with respect to", "{.var {vars2chr(by_vars)}}." ) |
print_not_mapped |
Print a list of unique Default: Permitted Values: |
The output dataset contains all observations and variables of the
input dataset, and add the variables specified in new_vars
from the lookup
table specified in dataset_add
. Optionally prints a list of unique
by_vars
values that do not have corresponding records
from the lookup table (by specifying print_not_mapped = TRUE
).
General Derivation Functions for all ADaMs that returns variable appended to dataset:
derive_var_extreme_flag()
,
derive_var_joined_exist_flag()
,
derive_var_merged_ef_msrc()
,
derive_var_merged_exist_flag()
,
derive_var_merged_summary()
,
derive_var_obs_number()
,
derive_var_relative_flag()
,
derive_vars_computed()
,
derive_vars_joined()
,
derive_vars_merged()
,
derive_vars_transposed()
library(dplyr, warn.conflicts = FALSE)
vs <- tribble(
~STUDYID, ~DOMAIN, ~USUBJID, ~VISIT, ~VSTESTCD, ~VSTEST,
"PILOT01", "VS", "01-1028", "SCREENING", "HEIGHT", "Height",
"PILOT01", "VS", "01-1028", "SCREENING", "TEMP", "Temperature",
"PILOT01", "VS", "01-1028", "BASELINE", "TEMP", "Temperature",
"PILOT01", "VS", "01-1028", "WEEK 4", "TEMP", "Temperature",
"PILOT01", "VS", "01-1028", "SCREENING 1", "WEIGHT", "Weight",
"PILOT01", "VS", "01-1028", "BASELINE", "WEIGHT", "Weight",
"PILOT01", "VS", "01-1028", "WEEK 4", "WEIGHT", "Weight",
"PILOT01", "VS", "04-1325", "SCREENING", "HEIGHT", "Height",
"PILOT01", "VS", "04-1325", "SCREENING", "TEMP", "Temperature",
"PILOT01", "VS", "04-1325", "BASELINE", "TEMP", "Temperature",
"PILOT01", "VS", "04-1325", "WEEK 4", "TEMP", "Temperature",
"PILOT01", "VS", "04-1325", "SCREENING 1", "WEIGHT", "Weight",
"PILOT01", "VS", "04-1325", "BASELINE", "WEIGHT", "Weight",
"PILOT01", "VS", "04-1325", "WEEK 4", "WEIGHT", "Weight",
"PILOT01", "VS", "10-1027", "SCREENING", "HEIGHT", "Height",
"PILOT01", "VS", "10-1027", "SCREENING", "TEMP", "Temperature",
"PILOT01", "VS", "10-1027", "BASELINE", "TEMP", "Temperature",
"PILOT01", "VS", "10-1027", "WEEK 4", "TEMP", "Temperature",
"PILOT01", "VS", "10-1027", "SCREENING 1", "WEIGHT", "Weight",
"PILOT01", "VS", "10-1027", "BASELINE", "WEIGHT", "Weight",
"PILOT01", "VS", "10-1027", "WEEK 4", "WEIGHT", "Weight"
)
param_lookup <- tribble(
~VSTESTCD, ~VSTEST, ~PARAMCD, ~PARAM,
"SYSBP", "Systolic Blood Pressure", "SYSBP", "Syst Blood Pressure (mmHg)",
"WEIGHT", "Weight", "WEIGHT", "Weight (kg)",
"HEIGHT", "Height", "HEIGHT", "Height (cm)",
"TEMP", "Temperature", "TEMP", "Temperature (C)",
"MAP", "Mean Arterial Pressure", "MAP", "Mean Art Pressure (mmHg)",
"BMI", "Body Mass Index", "BMI", "Body Mass Index(kg/m^2)",
"BSA", "Body Surface Area", "BSA", "Body Surface Area(m^2)"
)
derive_vars_merged_lookup(
dataset = vs,
dataset_add = param_lookup,
by_vars = exprs(VSTESTCD),
new_vars = exprs(PARAMCD, PARAM),
print_not_mapped = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.