shipunov (version 1.5)

Alldups: Finds all duplicates

Description

Finds duplicates from both ends, optionally returns indexes of duplicate groups

Usage

Alldups(v, groups=FALSE)

Arguments

v

vector

groups

If TRUE, 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'

Details

In short, this is extension of unique() which skips the first duplicate in each group. 'NA' count as duplicate but do not count as duplicate group.

See Also

unique

Examples

Run this code
# NOT RUN {
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))
# }

Run the code above in your browser using DataCamp Workspace