% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/loceq.R
\name{loceq}
\alias{loceq}
\title{Returns the locations of the elements of the first argument whose
values are equal to one of the elements in the second argument}
\usage{
loceq(a, b, keep = 1)
}
\arguments{
\item{a}{vector}

\item{b}{vector}

\item{keep}{= 1 not to sort the result}
}
\value{
vector consisting of the locations of the elements of
the first argument whose
values are equal to one of the elements in the second argument, or 0
}
\description{
Returns the locations of the elements of the first argument whose
values are equal to one of the elements in the second argument
}
\details{
\code{loceq( a, b, keep=0 )} is equivalent to \cr
\code{which( match(a,b, nomatch=0) > 0 ) } \cr
or \cr
\code{which( a \%in\% b )} .\cr

loceq(letters, c("x","cc","a"))  returns c(24,1) \cr
With keep=0, the result will be sorted according to the order
of appearance in the first argument.\cr
loceq(letters, c("x","cc","a"), 0)  returns c(1,24) \cr\cr
 If subset below contains a subset of the variable names of
 a data frame,\cr
 loc=loceq( colnames(dataframe), subset ) \cr
 wii return the location of those variables.\cr\cr
 It will return 0 if no match.
}
\examples{
loceq(letters, c("x","cc","a"))
loceq(letters, c("x","cc","a"), 0)
loceq(c("x","cc","a"), letters)
loceq(c("x","cc","a"), letters, 0)

}
