x <- rvec(list(c(1, 11),
c(2, 5),
c(22, 6)))
x > 10 ## rvec_lgl
## if_else_rvec needed when
## 'condition' is an rvec
if_else_rvec(x > 10, 10, x)
## dplyr::if_else works when
## 'true', 'false', or 'missing'
## (but not 'condition') are rvecs
library(dplyr)
if_else(c(TRUE, FALSE, TRUE), x, 100)
Run the code above in your browser using DataLab