\Header{Comparison}{Relational Operators}
\alias{"!=}{Comparison}
\alias{<}{Comparison}
\alias{<=}{Comparison}
\alias{==}{Comparison}
\alias{>}{Comparison}
\alias{>=}{Comparison}
\keyword{logic}{Comparison}
\begin{Description}\relax
Binary operators which allow the comparison of values in vectors.\end{Description}
\begin{Usage}
\begin{verbatim}
x < y
x > y
x <= y
x >= y
x == y
x != y
\end{verbatim}
\end{Usage}
\begin{Details}\relax
Comparison of strings in character vectors is lexicographic within the
strings using the collating sequence of the locale in use: see
\code{\Link{locales}}.  The collating sequence of locales such as
\code{en\_US} is normally different from \code{C} (which should use
ASCII) and can be surprising.\end{Details}
\begin{Value}
A vector of logicals indicating the result of the element by element
comparison.  The elements of shorter vectors are recycled as
necessary.

Objects such as arrays or time-series can be compared this way
provided they are conformable.\end{Value}
\begin{Note}\relax
Don't use \code{==} and \code{!=} for tests, such as in \code{if}
expressions, where you must get a single \code{TRUE} or
\code{FALSE}.  Unless you are absolutely sure that nothing unusual
can happen, you should use the \code{\Link{identical}} function
instead.

For numerical values, remember \code{==} and \code{!=} do not allow
for the finite representation of fractions, nor for rounding error.
Using \code{\Link{all.equal}} with \code{identical} is almost
always preferable.  See the examples.\end{Note}
\begin{SeeAlso}\relax
\code{\Link{Syntax}} for operator precedence.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- rnorm(20)
x < 1
x[x > 0]

x1 <- 0.5 - 0.3
x2 <- 0.3 - 0.1
x1 == x2                           # FALSE on most machines
identical(all.equal(x1, x2), TRUE) # TRUE everywhere
\end{ExampleCode}
\end{Examples}

