ifelse {base} R Documentation

Conditional Element Selection

Description


ifelse returns a value with the same shape as test which is filled with
elements selected from either yes or no depending on whether the
element of test is TRUE or FALSE.

Usage

ifelse(test, yes, no);

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.

Details

If yes or no are too short, their elements are recycled. yes will be evaluated if and only if any element of test is true, and analogously for no. Missing values In test give missing values In the result.

Authors

SMRUCC genomics Institute

Value

A vector of the same length and attributes (including dimensions and "class") as test and data values from the values of yes or no. The mode of the answer will be coerced from logical to accommodate first any values taken from yes and then any values taken from no.

clr value class

Examples


[Package base version 2.33.856.6961 Index]