prep_add_computed_variables {dataquieR} | R Documentation |
Insert missing codes for NA
s based on rules
Description
Insert missing codes for NA
s based on rules
Usage
prep_add_computed_variables(
study_data,
meta_data,
label_col,
rules,
use_value_labels
)
Arguments
study_data |
data.frame the data frame that contains the measurements |
meta_data |
data.frame the data frame that contains metadata attributes of study data |
label_col |
variable attribute the name of the column in the metadata with labels of variables |
rules |
data.frame with the columns:
|
use_value_labels |
logical In rules for factors, use the value labels,
not the codes. Defaults to |
Value
a list
with the entry:
-
ModifiedStudyData
: Study data with the new variables
Examples
## Not run:
study_data <- prep_get_data_frame("ship")
prep_load_workbook_like_file("ship_meta_v2")
meta_data <- prep_get_data_frame("item_level")
rules <- tibble::tribble(
~VAR_NAMES, ~RULE,
"BMI", '[BODY_WEIGHT_0]/(([BODY_HEIGHT_0]/100)^2)',
"R", '[WAIST_CIRC_0]/2/[pi]', # in m^3
"VOL_EST", '[pi]*([WAIST_CIRC_0]/2/[pi])^2*[BODY_HEIGHT_0] / 1000', # in l
)
r <- prep_add_computed_variables(study_data, meta_data,
label_col = "LABEL", rules, use_value_labels = FALSE)
## End(Not run)
[Package dataquieR version 2.5.1 Index]