Learn R Programming

fb4package (version 2.0.0)

validate_fraction: Validate fraction values (0-1 range)

Description

Specialized validator for fraction/proportion values.

Usage

validate_fraction(
  value,
  param_name,
  strategy = "strict",
  allow_zero = TRUE,
  allow_one = TRUE
)

Value

An object of class fb4_validation (see

validation_result). valid is TRUE when all values lie within \([0, 1]\) (or the bounds set by allow_zero

and allow_one). Out-of-range values are recorded in

errors (strategy "strict") or warnings

(strategy "warn").

Arguments

value

Value(s) to validate

param_name

Parameter name

strategy

Handling strategy

allow_zero

Whether zero is allowed

allow_one

Whether one is allowed

Examples

Run this code
validate_fraction(0.5, "diet_proportion")
validate_fraction(c(0.3, 0.7), "fractions")

Run the code above in your browser using DataLab