| inspect_log_base {inspector} | R Documentation |
Validate logarithmic bases
Description
inspect_log_base checks if an object is a valid a logarithmic
base. This can be useful to validate inputs in user-defined functions.
Usage
inspect_log_base(x)
Arguments
x |
An arbitrary object. |
Details
inspect_log_base conducts a series of tests to check if x is a
valid logarithmic base. Namely, inspect_log_base checks if:
-
xisNULLor empty. -
xis an atomic vector oflength1. -
xis numeric. -
xisNAorNaN. -
xis positive.
Value
inspect_log_base does not return any output. There are two possible
outcomes:
The call is silent if
xis a numeric vector oflength1 that is a valid logarithmic base.An informative error message is thrown otherwise.
See Also
-
bfactor_log_interpretfor the interpretation of the logarithms of Bayes factors. -
inspect_bfactor_logto check if an object is a numeric vector of valid logarithmic Bayes factor values.
Examples
# Calls that pass silently:
x1 <- 10
x2 <- exp(1)
x3 <- 0.5
inspect_log_base(x1)
inspect_log_base(x2)
inspect_log_base(x3)
# Calls that throw informative error messages:
mylist <- list(
NULL, numeric(0), TRUE, factor(10),
list(10), matrix(10), NaN, NA, -1, 0
)
try(inspect_log_base(mylist[[1]]))
try(inspect_log_base(mylist[[2]]))
try(inspect_log_base(mylist[[3]]))
try(inspect_log_base(mylist[[4]]))
try(inspect_log_base(mylist[[5]]))
try(inspect_log_base(mylist[[6]]))
try(inspect_log_base(mylist[[7]]))
try(inspect_log_base(mylist[[8]]))
try(inspect_log_base(mylist[[9]]))
try(inspect_log_base(mylist[[10]]))