\Header{ifelse}{Conditional Element Selection}
\keyword{logic}{ifelse}
\keyword{programming}{ifelse}
\begin{Description}\relax
\code{ifelse} returns a value with the same shape as
\code{test} which is filled with elements selected
from either \code{yes} or \code{no}
depending on whether the element of \code{test}
is \code{TRUE} or \code{FALSE}.
If \code{yes} or \code{no} are too short, their elements are recycled.\end{Description}
\begin{Usage}
\begin{verbatim}
ifelse(test, yes, no)
\end{verbatim}
\end{Usage}
\begin{SeeAlso}\relax
\code{\Link{if}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- c(6:-4)
sqrt(x)#- gives warning
sqrt(ifelse(x >= 0, x, NA))# no warning

## Note: the following also gives the warning !
ifelse(x >= 0, sqrt(x), NA)
\end{ExampleCode}
\end{Examples}

