duplicates: Find All Indices of Duplicated Elements

Description Usage Arguments Examples

View source: R/duplicates.R

Description

Unlike base R's 'duplicated' function, this function returns a vector of indices of all duplicated elements of a vector including the first instance.

Usage

1

Arguments

vector

A vector containing duplicated elements.

value

Parameter similar to grep's: if FALSE, a vector containing the indices of all duplicated elements will be returned, but if TRUE, the offending elements themselves are returned.

Examples

1
2
3
4
5
6
dup.vec <- c(1:9, 1:4, 11:15, 14:18)
duplicates(dup.vec)
[1] 1 2 3 4 10 11 12 13 17 18 19 20

duplicates(dup.vec, value = TRUE)
[1] 1 2 3 4 1 2 3 4 14 15 14 15

danjamesadams/Dantools documentation built on Aug. 24, 2019, 6:15 p.m.