type.in_range: Define a conformance rule to confirm that a numeric is in a...

View source: R/type-coerce.R

type.in_rangeR Documentation

Define a conformance rule to confirm that a numeric is in a set range

Description

This is anticipated to be part of a iface rule e.g.

Usage

type.in_range(min, max, include.min = TRUE, include.max = TRUE)

Arguments

min

the lower limit

max

the upper limit

include.min

is lower limit open (default TRUE)

include.max

is upper limit open (default TRUE)

Details

iface(test_col = integer + in_range(-10,10) ~ "An integer from -10 to 10")

Value

a function which checks the values and returns them if OK or throws an error if not

Examples

type.in_range(0,10,TRUE,TRUE)(0:10)
try(type.in_range(0,10,TRUE,FALSE)(0:10))
try(type.in_range(0,10,FALSE)(0:10))
type.in_range(0,10,FALSE,TRUE)(1:10)
type.in_range(0,10,TRUE,FALSE)(0:9)
type.in_range(0,Inf,FALSE,FALSE)(1:9)
try(type.in_range(0,10)(1:99))

interfacer documentation built on April 4, 2025, 6:13 a.m.