Alldups | R Documentation |
Finds duplicates from both ends, optionally returns indexes of duplicate groups
Alldups(v, groups=FALSE)
v |
Vector, matrix or data frame |
groups |
If TRUE, returns group indexes (non-duplicated are 0) |
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).
Logical vector of length equal to 'v', or numerical vector if 'groups=TRUE'
Alexey Shipunov
duplicated
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.