\Header{.in.}{Find Matching (or Non-Matching) Elements}
\alias{\%in\%}{.in.}
\alias{\%nin\%}{.in.}
\keyword{manip}{.in.}
\keyword{character}{.in.}
\begin{Description}\relax
For two vectors or scalars \code{a} and \code{b}, \code{a \%in\% b}
returns a vector of logical values corresponding to the elements in
\code{a}.  A value is \code{TRUE} if that element of \code{a} is found
somewhere in \code{b}, \code{FALSE} otherwise.  If \code{a} is a factor
object and \code{b} is numeric, converts \code{a} to its integer codes
before the comparison.  If \code{a} is numeric and \code{b} is
\code{factor}, converts \code{b} to codes.  \code{\%nin\%} returns
\code{TRUE} if the element in \code{a} is not in \code{b}.
\end{Description}
\begin{Usage}
\begin{verbatim}
a %in% b
a %nin% b
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{a}] a vector (numeric, character, factor)

\item[\code{b}] a vector (numeric, character, factor), matching the mode of a

\end{ldescription}
\end{Arguments}
\begin{Value}
vector of logical values with length equal to length of \code{a}.\end{Value}
\begin{SeeAlso}\relax
\code{\Link{match}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
w <- factor(c("a","b","c"))
w %in% c("b","c")
w %in% c(2,3)      #same as previous, but with warning

#Suppose that a variable x has levels "a", "b1", "b2" and you
#want to classify levels "b1" and "b2" as just "b".  You can use
#the %in% operator and do the following:
# levels(x)[levels(x) %in% c("b1","b2")] <- "b"
#Note that levels(x) <- list(b=c('b1','b2')) would be a better approach
\end{ExampleCode}
\end{Examples}

