Skip to contents

Given a quantile pair, check that it is valid. A valid quantile pair is a numeric vector of length 2 where both values are between 0 and 100, and the first number is smaller than the second.

Usage

validate_quant_pair(pair)

Arguments

pair

An element of quant_pairs

Value

NULL if valid. Error otherwise.

Examples

# valid
casteval:::validate_quant_pair(c(50, 70))

# invalid
try(casteval:::validate_quant_pair(c(70, 50)))
#> Error in casteval:::validate_quant_pair(c(70, 50)) : 
#>   first quantile in pair must be less than second quantile in pair

# invalid
try(casteval:::validate_quant_pair(c(-1, 50)))
#> Error in casteval:::validate_quant_pair(c(-1, 50)) : 
#>   quantiles in pair must be between 0 and 100, inclusive

# invalid
try(casteval:::validate_quant_pair(c(50,60,70)))
#> Error in casteval:::validate_quant_pair(c(50, 60, 70)) : 
#>   quantile pair must have length 2

# invalid
try(casteval:::validate_quant_pair("50, 60"))
#> Error in casteval:::validate_quant_pair("50, 60") : 
#>   quantile pair must be vector of 2 numbers