Test whether an object contains numeric values from the interval [0,1]
Test whether an object contains numeric values from the interval [0,1]
Check if the input consists only of numeric values between 0 and 1, inclusive. This is often useful when validating truth degrees, membership values in fuzzy sets, or probabilities.
is_degree(x, na_rm =FALSE)
Arguments
x: The object to be tested. Can be a numeric vector, matrix, or array.
na_rm: Logical; whether to ignore NA values. If TRUE, NAs are treated as valid values. If FALSE and x contains any NAs, the function immediately returns FALSE.
Returns
A logical scalar. Returns TRUE if all (non-NA) elements of x
are numeric and lie within the closed interval [0,1]. Returns FALSE if: