Learn R Programming

rkeops (version 2.2.2)

ifelse: Element-wise if-else function

Description

Symbolic element-wise if-else function for LazyTensor objects or standard element-wise if-else function otherwise.

Usage

ifelse(test, yes, no)

Value

See value of ifelse.default() or ifelse.LazyTensor()

Arguments

test, yes, no

input for ifelse.default() or ifelse.LazyTensor().

Author

Chloe Serre-Combe, Amelie Vernay

Details

If test is a LazyTensor, see ifelse.LazyTensor(), else see ifelse.default().

See Also

ifelse.default(), ifelse.LazyTensor()

Examples

Run this code
if (FALSE) {
# R base operation
x <- c(6:-4)
sqrt(ifelse(x >= 0, x, NA))
# LazyTensor symbolic element-wise square
D <- 3
M <- 100
N <- 150
P <- 200
x <- matrix(runif(M * D), M, D)
y <- matrix(runif(N * D), N, D)
z <- matrix(runif(P * D), P, D)
x_i <- LazyTensor(x, index = 'i')
y_j <- LazyTensor(y, index = 'j')
z_i <- LazyTensor(z, index = 'i')

if_else_xyz <- ifelse(x_i, y_j, z_i)
}

Run the code above in your browser using DataLab