| check_bounded_double_scalar | R Documentation |
Check double scalar within bounds
check_bounded_double_scalar(
x,
lower = -Inf,
upper = Inf,
lower_open = FALSE,
upper_open = FALSE,
arg_name = deparse(substitute(x))
)
x |
Numeric: Value to check. Must be a single finite non-NA number. |
lower |
Numeric scalar: Lower bound. |
upper |
Numeric scalar: Upper bound. |
lower_open |
Logical scalar: If |
upper_open |
Logical scalar: If |
arg_name |
Character: Argument name to use in error messages. |
For bounds not covered by the fixed-range checks (check_prob_scalar is [0, 1],
check_pos_double_scalar is (0, Inf)), or where the range is not known until
runtime. The argument-checking counterpart to prop_float, whose min/max
and exclusive_min/exclusive_max describe the same intervals for a config
class. Finite like it: Inf/-Inf are rejected even where the matching bound
is unbounded, since an infinite bound is always an open one.
Called for side effects. Throws an error if checks fail.
EDG
check_bounded_double_scalar(0.7, lower = 0, upper = 2)
# Learning rate in (0, 1]
check_bounded_double_scalar(0.1, lower = 0, upper = 1, lower_open = TRUE)
# Throw error:
try(check_bounded_double_scalar(5, lower = 0, upper = 2))
try(check_bounded_double_scalar(Inf, lower = 0))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.