unique_by {funprog} | R Documentation |
Unique with auxiliary function
Description
Remove duplicate elements, given a transformation.
Usage
unique_by(x, f, first = TRUE)
Arguments
x |
a vector or a list. |
f |
a function to apply to each element of |
first |
if several elements are identical after being transformed by
|
Value
An object of the same type as x. Only elements that are unique after
being transformed by f
are kept.
Examples
unique_by(-3:2, abs)
unique_by(-3:2, abs, first = FALSE)
unique_by(c(1, 2, 4, 5, 6), function(x) x %% 3)
unique_by(list(1:2, 2:3, 2:4), length)
[Package funprog version 0.3.0 Index]