tiepos
returns the positions of those elements that participate in ties.
Arguments
- x
a vector or a data frame or an array or
NULL
.- ...
ignored
- nties
NULL or the number of tied values (including NA). Providing
nties
can speed-up whenx
has no cache. Note that a wrong nties can cause undefined behaviour up to a crash.- method
NULL for automatic method selection or a suitable low-level method, see details
Details
This function automatically chooses from several low-level functions
considering the size of x
and the availability of a cache.
Suitable methods are
sortordertie
(fast ordering)ordertie
(memory saving ordering).
See also
rank.integer64()
for possibly tied ranks and unipos.integer64()
for positions of unique values.
Examples
x <- as.integer64(sample(c(rep(NA, 9), 1:9), 32, TRUE))
tiepos(x)
#> [1] 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#> [24] 25 26 28 30 31 32
stopifnot(identical(tiepos(x), (1:length(x))[duplicated(x) | rev(duplicated(rev(x)))]))