Alldups {shipunov} | R Documentation |
Finds all duplicates
Description
Finds duplicates from both ends, optionally returns indexes of duplicate groups
Usage
Alldups(v, groups=FALSE)
Arguments
v |
Vector, matrix or data frame |
groups |
If TRUE, returns group indexes (non-duplicated are 0) |
Details
This is extension of duplicated() which _does not_ skip the first duplicate in each group. 'NA' consider for duplicates but do not count as duplicate group.
If the first argument is a matrix or data frame and 'groups=TRUE', Aldups() starts from converting them into character vector with paste0(..., collapse="").
If 'groups=TRUE', Alldups() uses as.numeric(as.character(v)) twice to index duplicated groups with natural numbers (and non-duplicated with 0).
Value
Logical vector of length equal to 'v', or numerical vector if 'groups=TRUE'
Author(s)
Alexey Shipunov
See Also
Examples
aa <- c("one", "two", "", NA, "two", "three", "three", "three", NA, "", "four")
Alldups(aa)
data.frame(v=aa, dups=Alldups(aa), groups=Alldups(aa, groups=TRUE))
## clustering based on duplicates from rounding
(iris.dgr <- Alldups(round(iris[, 1:4]/10), groups=TRUE))
Misclass(iris.dgr, iris$Species, best=TRUE)
[Package shipunov version 1.17.1 Index]