Learn R Programming

ojUtils (version 0.1.0)

ifelseC: ifelse replacement

Description

This function is a port of ifelse from base. Usually the behaviour should be identical.

Usage

ifelseC(test, yes, no)

Arguments

test

logical vector or an object that can be compressed to a logical vector

yes

numerical, character, integer or logical vector for cases where test is TRUE.

no

numerical, character, integer or logical vector for cases where test is FALSE.

Details

The parameters must have the same length, or, in the case of yes or no, length must be 1.

Examples

Run this code
# NOT RUN {
test = c(TRUE,FALSE,NA); yes = c(1,1,1); no = c(2,2,2)
all(ifelseC(test, yes, no) == ifelse(test, yes, no))
# }

Run the code above in your browser using DataLab