unduplicate: Remove duplicate elements

unduplicateR Documentation

Remove duplicate elements

Description

Remove duplicated elements from an object. Simple wrapper for base::duplicated() to use in functional contexts.

Usage

unduplicate(x)

Arguments

x

An object.

Details

Calls either x[!duplicated(x)] or x[!duplicated(x), ] depending on input dimensions. Will work for objects with a defined method for base::duplicated().

Value

Object of the same type as input.

Examples

#simple vector
simple_vector = sample(1:5, size = 20, replace = T) %T>% print
simple_vector %>% unduplicate
#example on iris (data frame)
iris_with_dups = iris[c(1, 1, 2, 2, 3, 4, 1, 5, 2, 4), ] %T>% print
iris_with_dups %>% unduplicate

Deleetdk/kirkegaard documentation built on April 22, 2024, 5:22 p.m.