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 (util_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 meta data frame and ds1
is produced by a preceding call
of util_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,
need_type,
role = ""
)util_correct_variable_use2(
arg_name,
allow_na,
allow_more_than_one,
allow_null,
allow_all_obs_na,
allow_any_obs_na,
need_type,
role = arg_name
)
character Name of a function argument of the caller of util_correct_variable_use
logical default = FALSE. allow NAs in the variable names
argument given in arg_name
logical default = FALSE. allow more than one
variable names in arg_name
logical default = FALSE. allow an empty variable name
vector in the argument arg_name
logical default = TRUE. check observations for not
being all NA
logical default = TRUE. check observations for
being complete without any NA
character if not NA
, variables must be of data type
need_type
according to the meta data,
can be a pipe (|
) separated list of
allowed data types. Use !
to exclude
a type. See DATA_TYPES for the
predefined variable types of the
dataquieR
concept.
character variable-argument role. Set different defaults for
all allow
-arguments and need_type
of
this util_correct_variable_use.
. If given, it
defines the intended use
of the verified argument. For typical arguments and
typical use cases, roles
are predefined in .variable_arg_roles.
The role's defaults can be overwritten by the
arguments. If role
is "" (default),
the standards are allow_na = FALSE
,
allow_more_than_one = FALSE
, allow_null = FALSE
,
allow_all_obs_na = TRUE
, allow_any_obs_na = TRUE
,
and need_type = NA
.
Use util_correct_variable_use2 for using the
arg_name
as default for role
.
See .variable_arg_roles for currently available
variable-argument roles.
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!