Skip to contents

This function checks a given vector for several conditions, including values being within the range 0 to 1 inclusive, the sum of values being equal to 1, no duplicate names, and all elements having names.

Usage

check_init(x)

Arguments

x

A numeric vector with named elements.

Value

If successful there is no message, otherwise, it issues warnings with informative messages for each failed condition.

Examples

if (FALSE) { # \dontrun{
x <- setNames(object = c(0.2, 0.3, 0.4, 0.1), nm = letters[1:4])
check_init(x) # Should issue warnings for values outside 0-1 and the sum not equal to 1

x <- c(0.2, 0.3, 0.4, 0.1) # Missing names
check_init(x) # Should issue a warning about missing names

x <- c(-2, 0.3, 0.4, 0.1) # Missing names
check_init(x) # Should issue a warning about a value below 0 and about not summing to 1
} # }