Return the number of discrete values in x that lie between
from and to, or test whether the number of discrete values is infinite.
Usage
num_discretes(
x,
from = -Inf,
to = Inf,
...,
include_from = TRUE,
include_to = TRUE,
tol = sqrt(.Machine$double.eps)
)Arguments
- x
Numeric series (
numericvector or object of class"discretes").- from, to
Reference values, possibly infinite.
frommust be less than or equal toto; both must be length-1 numeric vectors.- ...
Reserved for future extensions; must be empty.
- include_from, include_to
Should the
fromvalue be included in the query? Should thetovalue? Both must be length-1 logical vectors.- tol
Numerical tolerance when checking if a value is in the series. Single non-negative numeric. See
next_discrete()for details.
Value
For num_discretes(),
a single non-negative integer, or possibly Inf for infinitely many
discrete values.
Examples
num_discretes(-3:3)
#> [1] 7
num_discretes(c(0.4, 0.4, 0.4, 0))
#> [1] 2
x <- arithmetic(-3.2, spacing = 0.5)
num_discretes(x)
#> [1] Inf
num_discretes(x, from = -2, to = 2)
#> [1] 8
num_discretes(1 / x, from = -2, to = 2)
#> [1] Inf
