Skip to contents

If Else wrapper using kit::iif()

Usage

iif_else(x, yes, no)

Arguments

x

<logical> vector

yes, no

Values to return depending on TRUE/FALSE element of x. Must be same type and be either length 1 or same length of x.

Value

vector of same length as x and attributes as yes. Data values are taken from values of yes and no.

Examples

x <- c(1:4, 3:2, 1:4)

iif_else(x > 2L, x, x - 1L)
#>  [1] 0 1 3 4 3 1 0 1 3 4