.BG
.VE $Header: /usr3/s/current/s/.help/RCS/ifelse,v 1.2 83/12/30 19:29:22 rab Exp $
.FN ifelse
.TL
ifelse: Conditional Data Selection
.CS
ifelse(cond, true, false)
.PP
.AG cond
logical structure.
.AG true
vector containing values to be returned if `cond' is TRUE.
.AG false
vector containing values to be returned if `cond' is FALSE.
.RT
vector like `cond'.  The result is made up element-by-element
from the values from `true' or `false' depending on
`cond'.  If `true' or `false' are not as large as `cond',
they will be repeated cyclically.  Missing values (NAs) are
allowed.  NA values in `cond' cause NA to be returned.
.EX
ifelse(x>1,1,x)  # gives the value 1 if x>1 else gives x
            # equivalent to pmin(1,x)
.PP
Evaluation of arguments is done before execution of ifelse. 
Divide-by-zero will already have occurred in `ifelse(x==0,NA,1/x)' by the
time `ifelse' is executed. 
Avoid the zero-divide by using `1/ifelse(x==0,NA,x)'.
.PP
The `if' syntax construct of the S language provides conditional
evaluation.
.KW basic*
.KW logic
.KW manip
.WR
