View source: R/util_correct_variable_use.R
util_correct_variable_use | R Documentation |
This function operates in the environment of its caller
(using eval.parent, similar to Function like C-Preprocessor-Macros
).
Different from the other utility function that work
in the caller's environment (prep_prepare_dataframes), It has no side
effects except that the argument
of the calling function specified in arg_name
is normalized (set to its
default or a general default if missing, variable names being all white
space replaced by NAs).
It expects two objects in the caller's environment: ds1
and meta_data
.
meta_data
is the metadata data frame and ds1
is produced by a preceding
call of prep_prepare_dataframes using meta_data
and study_data
.
util_correct_variable_use(
arg_name,
allow_na,
allow_more_than_one,
allow_null,
allow_all_obs_na,
allow_any_obs_na,
min_distinct_values,
need_type,
need_scale,
role = "",
overwrite = TRUE,
do_not_stop = FALSE,
remove_not_found = TRUE
)
util_correct_variable_use2(
arg_name,
allow_na,
allow_more_than_one,
allow_null,
allow_all_obs_na,
allow_any_obs_na,
min_distinct_values,
need_type,
need_scale,
role = arg_name,
overwrite = TRUE,
do_not_stop = FALSE,
remove_not_found = TRUE
)
arg_name |
character Name of a function argument of the caller of util_correct_variable_use |
allow_na |
logical default = FALSE. allow NAs in the variable names
argument given in |
allow_more_than_one |
logical default = FALSE. allow more than one
variable names in |
allow_null |
logical default = FALSE. allow an empty variable name
vector in the argument |
allow_all_obs_na |
logical default = TRUE. check observations for not
being all |
allow_any_obs_na |
logical default = TRUE. check observations for
being complete without any |
min_distinct_values |
integer Minimum number of distinct observed values of a study variable |
need_type |
character if not |
need_scale |
character if not |
role |
character variable-argument role. Set different defaults for
all |
overwrite |
logical overwrite vector of variable names
to match the labels given in |
do_not_stop |
logical do not throw an error, if one of the variables
violates |
remove_not_found |
TODO: Not yet implemented |
util_correct_variable_use and util_correct_variable_use2 differ only in
the default of the argument role
.
util_correct_variable_use and util_correct_variable_use2 put strong
effort on producing compressible
error messages to the caller's caller (who is typically an end user of
a dataquieR
function).
The function ensures, that a specified argument of its caller that refers variable names (one or more as character vector) matches some expectations.
This function accesses the caller's environment!
.variable_arg_roles
Other robustness_functions:
util_as_valid_missing_codes()
,
util_check_one_unique_value()
,
util_empty()
,
util_ensure_character()
,
util_ensure_in()
,
util_ensure_suggested()
,
util_expect_scalar()
,
util_fix_rstudio_bugs()
,
util_is_integer()
,
util_is_numeric_in()
,
util_is_valid_missing_codes()
,
util_match_arg()
,
util_observations_in_subgroups()
,
util_only_NAs()
,
util_stop_if_not()
,
util_warn_unordered()
Other robustness_functions:
util_as_valid_missing_codes()
,
util_check_one_unique_value()
,
util_empty()
,
util_ensure_character()
,
util_ensure_in()
,
util_ensure_suggested()
,
util_expect_scalar()
,
util_fix_rstudio_bugs()
,
util_is_integer()
,
util_is_numeric_in()
,
util_is_valid_missing_codes()
,
util_match_arg()
,
util_observations_in_subgroups()
,
util_only_NAs()
,
util_stop_if_not()
,
util_warn_unordered()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.