This function takes a numeric or character vector and returns a vector of the unique elements that appear more than once - so a simple shortcut for unique(x[duplicated(x)]) that is particularly friendly in pipes

dupl_items(x)

Arguments

x

A numeric or character vector from which to identify duplicate elements.

Value

A vector containing unique elements that are duplicated in the original vector. Returns an empty vector if there are no duplicates.

Examples

dupl_items(c(1, 2, 3, 3, 4, 5, 5, 5))
#> [1] 3 5
# Output: 3 5
dupl_items(c(1, 2, 3, 4))
#> numeric(0)
# Output: numeric(0)