check_if_named_numeric_vector {dRiftDM} | R Documentation |
Check if Object is a Named Numeric Vector
Description
Validates that an object is a named numeric vector with specified attributes. Optionally checks specific names, length, and restrictions on label characters.
Usage
check_if_named_numeric_vector(
x,
var_name,
labels = NULL,
length = NULL,
allow_non_word_chars = FALSE
)
Arguments
x |
numeric vector, expected to be named. |
var_name |
character, the name of the variable to display in error messages. |
labels |
character vector, optional, specifying valid names for |
length |
integer, optional, specifying the exact required length of |
allow_non_word_chars |
logical, whether to permit non-word characters in
names (default is |
Details
Checks for:
Numeric type of
x
with non-zero lengthRequired length, if specified
Unique, non-empty names for each entry in
x
Match of all names in
x
tolabels
, iflabels
is specifiedAbsence of
NA
ofInf
values inx
Optional absence of non-word names if
allow_non_word_chars
is FALSE
Value
Throws an error if the conditions are not met. If all checks pass, no output is returned.