| missing | R Documentation |
Detect or remove missing and infinite values in rvecs.
Operations are done independently on each draw,
though na.omit(), na.exclude(), and na.fail()
also look across draws.
## S3 method for class 'rvec'
anyNA(x, recursive = FALSE)
## S3 method for class 'rvec'
is.na(x)
## S3 method for class 'rvec'
na.exclude(object, ...)
## S3 method for class 'rvec'
na.omit(object, ...)
x, object |
An rvec. |
recursive |
Whether |
... |
Currently ignored. |
The behavior of the rvec methods
for is.na(), is.nan(),
is.finite(), and is.infinite()
differs from the standard
vctrs
behavior, which is to return a logical
vector with length equal to length(x).
With rvecs, the standard vctrs behavior
would entail summarising across draws,
which is the job of the draws_*
functions.
anyNA() A logical rvec with length 1.
is.na(), is.nan(), is.finite(), is.infinite() A
logical rvec with the same length as the original rvec.
na.omit(), na.exclude() An rvec with the same
class as the original rvec, minus any elements that
have NAs in any draws.
na.fail() The original rvec, or an error.
if_else_rvec() Modify individual
values within draws
is.na(), is.nan(),
is.finite(), is.infinite(),
anyNA(), na.omit(), na.exclude() Base R functions
vctrs::vec_detect_missing() Test whether
all draws for an observation are missing
vctrs::vec_detect_complete() Test whether
any draws for an observation are missing
draws_any(), draws_all() Summarise
across draws
x <- rvec(list(c(1.2, NA),
c(Inf, 3),
c(-1, NaN)))
## return a logical rvec
is.na(x)
is.nan(x)
is.finite(x)
is.infinite(x)
## return a logical rvec with length 1
anyNA(x)
## summarise across draws
draws_any(anyNA(x))
## return an NA-free version of 'x'
na.omit(x)
na.exclude(x)
## use 'if_else_rvec' to modify values
## within rvec
if_else_rvec(is.na(x), 999, x)
## vctrs functions
library(vctrs, warn.conflicts = FALSE)
## all draws missing
vec_detect_missing(x)
## any draws missing
vec_detect_complete(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.