\Header{match}{Value Matching}
\alias{$\%$in$\%$}{match}
\keyword{manip}{match}
\keyword{logic}{match}
\begin{Usage}
\begin{verbatim}
match(x, table, nomatch=NA)
x %in% table
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{x}] the values to be matched.
\item[\texttt{table}] the values to be matched against.
\item[\texttt{nomatch}] the value to be returned in the case when no match is found.
\end{ldescription}
\end{Arguments}
\begin{Description}
\texttt{match}: If \texttt{x[i]} is found to equal \texttt{table[j]}
then the value returned in the \texttt{i}-th position of the return value is
\texttt{j}.  If no match is found, the value is \texttt{nomatch}.

\texttt{\%in\%}: A utility function, currently defined as \\{}
\texttt{"\%in\%" <- function(x, y) match(x, y, nomatch = 0) > 0} allowing
an intuitive usage and returning a logical vector of length \texttt{length(x)}.\end{Description}
\begin{SeeAlso}
\texttt{\Link{pmatch}} and \texttt{\Link{charmatch}} for (\emph{partial})
string matching, \texttt{\Link{match.arg}}, etc for function argument matching.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
## The intersection of two sets :
intersect <- function(x, y) y[match(x, y, nomatch = 0)]
intersect(1:10,7:20)

1:10 %in% c(1,3,5,9)
sstr <- c("c","ab","B","bba","c","@","bla","a","Ba","%")
sstr[sstr %in% c(letters,LETTERS)]

"%w/o%" <- function(x,y) x[!x %in% y] #--  x without y
(1:10) %w/o% c(3,7,12)
\end{ExampleCode}
\end{Examples}

