ifelse

Vectorized If-Else

Evaluates a condition and returns values from true_val or false_val depending on the condition. Supports missing value handling via the missing argument.

Parameters

Returns

A scalar when condition is scalar, otherwise a vector aligned to condition.

Examples

ifelse([true, false, NA], "Yes", "No", missing = "Unknown")