Skip to contents

This function validates whether a numeric value is a valid proportion scalar (ranging from 0 to 1, inclusive).

Usage

validate_proportion(x)

Arguments

x

Numeric value to validate as a proportion.

Value

TRUE if x is a valid proportion, otherwise it throws an error.

Examples

validate_proportion(0.5) # TRUE
#> [1] TRUE
try(validate_proportion(1.2)) # Error
#> Error in validate_proportion(1.2) : Not a valid proportion