Skip to contents

This function checks if a numeric value is a proportion scalar, meaning it is numeric and within the range of 0 to 1 (inclusive).

Usage

is_proportion(x)

Arguments

x

Numeric value to check.

Value

TRUE if x is a proportion, otherwise FALSE.

Examples

is_proportion(0.5) # TRUE
#> [1] TRUE
is_proportion(1.2) # FALSE
#> [1] FALSE
is_proportion(-0.2) # FALSE
#> [1] FALSE