ifelseR 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

## S4 method for signature 'fm,fm,ANY'
ifelse(test, yes, no)

## S4 method for signature 'fm,ANY,fm'
ifelse(test, yes, no)

## S4 method for signature 'fmV,fmV,ANY'
ifelse(test, yes, no)

## S4 method for signature 'fmV,ANY,fmV'
ifelse(test, yes, no)

Arguments

test

a logical FlashR vector or matrix.

yes

a FlashR vector or matrix or an R scalar.

no

a FlashR vector or matrix or an R scalar.

Details

The current implementation requires either yes or no to be a scalar value.

Value

A FlashR vector or matrix of the same size and attributes (including dimensions) as test and data values from the values of yes or no.

Examples

mat <- fm.runif.matrix(100, 10)
mat <- ifelse(mat > 0.5, mat, 0)