duplicated_all: Determine **all** duplicated elements

View source: R/utils.R

duplicated_allR Documentation

Determine **all** duplicated elements

Description

Similar to duplicated but returns all elements that are identified as a duplicate element (i.e. not just the duplicated elements following the first identified row as is default in R base duplicated).

Usage

duplicated_all(x, ...)

Arguments

x

A vector of values to determine duplicated elements (can be 1 or more columns).

...

Additional parameters passed to duplicated

Details

Should also work with data.table objects. To index all duplicated elements by multiple fields, provide them as a vector of names to the dataset. data.table uses by as a parameter for a similar purpose but this function follows the base R syntax of duplicated().

Value

Logical vector of index for duplicated elements.

Examples

testing <- data.frame(col1 = c(1, 1, 1, 2, 3, 3, 3),
                      col2 = c(0, 100, 0, 100, 100.1, 101.10101, 100.00))
index1 <- duplicated_all(testing[,c('col1')])
index2 <- duplicated_all(testing[,c('col2')])
index3 <- duplicated_all(testing[,c('col1', 'col2')])
testing[index1,]
testing[index2,]
testing[index3,]

al-obrien/farrago documentation built on April 14, 2023, 6:20 p.m.