Learn R Programming

salad (version 1.2)

ifelse: Conditionnal Element Selection

Description

`ifelse` methods extend `base::ifelse` to allow using dual objects for 'yes' or 'no' arguments.

Usage

ifelse(test, yes, no)

Value

A dual object (dual vector).

Arguments

test

an object which can be coerced to logical mode.

yes

return values for true elements of 'test'.

no

return values for false elements of 'test'.

Examples

Run this code
x <- dual(c(1,2,4,6))
y <- ifelse(x > 2, x, x/2)
y
d(y)

Run the code above in your browser using DataLab