x <- 1
check_n(x)
x <- 1L
check_n(x)
sapply(c(1, 2.1, 0, Inf, NA, -9), is_n)
if (FALSE) {
# `x` must be a numeric
x <- "1"
check_n(x)
# `x` must have length 1
x <- 1:2
check_n(x)
# `x` must not be `NA`
x <- NA_integer_
check_n(x)
# `x` must be larger than 0
x <- -1
check_n(x)
# `x` must be an integer in a mathematical sense
x <- 1.1
check_n(x)
# make `0` acceptable
x <- 0
check_n(x)
check_n(x, zero = TRUE)
}
Run the code above in your browser using DataLab