1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
\name{duplicated2}
\alias{duplicated2}
\title{Determine Duplicate Elements}
\description{
\code{duplicated2()} determines which elements of a vector or data
frame are duplicates, and returns a logical vector indicating which
elements (rows) are duplicates.
}
\usage{
duplicated2(x, bothWays=TRUE, \dots)
}
\arguments{
\item{x}{a vector or a data frame or an array or \code{NULL}.}
\item{bothWays}{if \code{TRUE} (the default), duplication should be
considered from both sides. For more information see the argument
\code{fromLast} to the function \code{\link{duplicated}}.}
\item{\dots}{further arguments passed down to \code{duplicated()} and
its methods.}
}
\details{
The standard \code{\link{duplicated}} function (in \code{package:base})
only returns \code{TRUE} for the second and following copies of each
duplicated value (second-to-last and earlier when
\code{fromLast=TRUE}). This function returns all duplicated
elements, including the first (last) value.
When \code{bothWays} is \code{FALSE}, \code{duplicated2()} defaults to
a \code{\link{duplicated}} call. When \code{bothWays} is \code{TRUE},
the following call is being executed:
\code{duplicated(x, \dots) | duplicated(x, fromLast=TRUE, \dots)}
}
\value{
For a vector input, a logical vector of the same length as
\code{x}. For a data frame, a logical vector with one element for
each row. For a matrix or array, and when \code{MARGIN = 0}, a
logical array with the same dimensions and dimnames.
For more details see \code{\link{duplicated}}.
}
\seealso{
\code{\link[base]{duplicated}}, \code{\link[base]{unique}}
}
\author{Liviu Andronic}
\examples{
iris[duplicated(iris), ] # 2nd duplicated value
iris[duplicated(iris, fromLast=TRUE), ] # 1st duplicated value
iris[duplicated2(iris), ] # both duplicated values
}
\keyword{logic}
\keyword{manip}
|