Learn R Programming

toscutil (version 2.8.0)

ifthen: Shortcut for multiple if else statements

Description

ifthen(a, b, c, d, e, f, ...) == if (a) b else if (c) d else if (e) f

Usage

ifthen(...)

Value

ifelse returns the first value for which the corresponding statement evaluates to TRUE

Arguments

...

pairs of checks and corresponding return values

Examples

Run this code
x <- 2
y <- 2
z <- 1
ifthen(x == 0, "foo", y == 0, "bar", z == 1, "this string gets returned")

Run the code above in your browser using DataLab