Special value predicates for random variables
Source:R/rvar-summaries-within-draws.R
rvar_is_finite.RdCompute special value predicates (checking for finite / infinite values, NaN, and NA)
on all draws within a random variable, returning a random variable.
Arguments
- x
(rvar) An
rvar.
Value
A logical rvar of the same length as the input.
Details
These functions return a new rvar that is the result of applying
is.finite(), is.infinite(), is.nan(), or is.na() to every draw
in the input random variable.
See also
rvar-summaries-over-draws for summary functions across draws, including
implementations of is.finite(), is.infinite(), is.nan(), and is.na() for
rvars.
Other rvar-summaries:
rvar-summaries-over-draws,
rvar-summaries-within-draws
Examples
x <- rvar(c(1, Inf, -Inf, NaN, NA))
x
#> rvar<5>[1] mean ± sd:
#> [1] NA ± NA
rvar_is_finite(x)
#> rvar<5>[1] mean ± sd:
#> [1] 0.2 ± 0.45
rvar_is_infinite(x)
#> rvar<5>[1] mean ± sd:
#> [1] 0.4 ± 0.55
rvar_is_nan(x)
#> rvar<5>[1] mean ± sd:
#> [1] 0.2 ± 0.45
rvar_is_na(x)
#> rvar<5>[1] mean ± sd:
#> [1] 0.4 ± 0.55