# NOT RUN {
# ways to succeed:
is_prob(1/2) # => TRUE
p.seq <- seq(0, 1, by = .1) # Vector of probabilities
is_prob(p.seq) # => TRUE (for vector)
## watch out for:
# is_prob(NA) # => FALSE + NO warning!
# is_prob(0/0) # => FALSE + NO warning (NA + NaN values)
# is_prob(0/0, NA_warn = TRUE) # => FALSE + warning (NA values)
## ways to fail:
# is_prob(8, NA_warn = TRUE) # => FALSE + warning (outside range element)
# is_prob(c(.5, 8), NA_warn = TRUE) # => FALSE + warning (outside range vector element)
# is_prob("Laplace", NA_warn = TRUE) # => FALSE + warning (non-numeric values)
# }
Run the code above in your browser using DataLab