| 1 |
\name{Duplicated} |
| 2 |
\alias{Duplicated} |
| 3 |
\title{Counting-Generalization of duplicated()} |
| 4 |
\description{ |
| 5 |
Duplicated() generalizes the \code{\link{duplicated}} method for |
| 6 |
vectors, by returning indices of \dQuote{equivalence classes} for |
| 7 |
duplicated entries and returning \code{nomatch} (\code{NA} by default) |
| 8 |
for unique entries. |
| 9 |
|
| 10 |
Note that \code{duplicated()} is not \code{TRUE} for the first time a |
| 11 |
duplicate appears, whereas \code{Duplicated()} only marks unique |
| 12 |
entries with \code{nomatch} (\code{NA}). |
| 13 |
} |
| 14 |
\usage{ |
| 15 |
Duplicated(v, incomparables = FALSE, fromLast = FALSE, nomatch = NA_integer_) |
| 16 |
} |
| 17 |
\arguments{ |
| 18 |
\item{v}{a vector, often character, factor, or numeric.} |
| 19 |
\item{incomparables}{a vector of values that cannot be compared, |
| 20 |
passed to both \code{\link{duplicated}()} and \code{\link{match}()}. |
| 21 |
\code{FALSE} is a special value, meaning that all values can be |
| 22 |
compared, and may be the only value accepted for methods other than |
| 23 |
the default. It will be coerced internally to the same type as \code{x}.} |
| 24 |
\item{fromLast}{logical indicating if duplication should be considered |
| 25 |
from the reverse side, i.e., the last (or rightmost) of identical |
| 26 |
elements would correspond to \code{duplicated=FALSE}.} |
| 27 |
\item{nomatch}{passed to \code{\link{match}()}: the value to be |
| 28 |
returned in the case when no match is found. Note that it is |
| 29 |
coerced to \code{integer}.} |
| 30 |
} |
| 31 |
\value{ |
| 32 |
an integer vector of the same length as \code{v}. Can be used as a |
| 33 |
\code{\link{factor}}, e.g., in \code{\link{split}}, |
| 34 |
\code{\link{tapply}}, etc. |
| 35 |
} |
| 36 |
\author{Christoph Buser and Martin Maechler, Seminar fuer Statistik, ETH |
| 37 |
Zurich, Sep.2007} |
| 38 |
\seealso{\code{\link{uniqueL}} (also in this \pkg{sfsmisc} package); |
| 39 |
\code{\link{duplicated}}, \code{\link{match}}. |
| 40 |
} |
| 41 |
\examples{ |
| 42 |
x <- c(9:12, 1:4, 3:6, 0:7) |
| 43 |
data.frame(x, dup = duplicated(x), |
| 44 |
dupL= duplicated(x, fromLast=TRUE), |
| 45 |
Dup = Duplicated(x), |
| 46 |
DupL= Duplicated(x, fromLast=TRUE)) |
| 47 |
} |
| 48 |
\keyword{manip} |