| rvar_ifelse | R Documentation |
A version of ifelse() that returns an rvar.
rvar_ifelse(test, yes, no)
test |
(logical |
yes |
( |
no |
( |
An rvar with the common type of yes and no (as determined by
vctrs::vec_cast_common()) and a shape determined by broadcasting test,
yes, and no to a common shape (see the section on broadcasting rules in
vignette("rvar")). For every element of draws_of(test), the corresponding
element of draws_of(yes) or draws_of(no) is placed into the result,
depending on whether the element of test is TRUE or FALSE.
x <- rvar(1:4)
y <- rvar(5:8)
i <- rvar(c(TRUE,FALSE,TRUE,FALSE))
z <- rvar_ifelse(i, x, y)
z
draws_of(z)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.