keypos returns the positions of the (fact table) elements that participate
in their sorted unique subset (dimension table)
Value
an integer vector of the same length as x containing positions
relative to sort(unique(x), na.last=FALSE)
Details
NAs are sorted first in the dimension table, see ramorder.integer64().
This function automatically chooses from several low-level functions
considering the size of x and the availability of a cache.
Suitable methods are
sortorderkey(fast ordering)orderkey(memory saving ordering).
See also
unique.integer64() for the unique subset and match.integer64()
for finding positions in a different vector.
Examples
x <- as.integer64(sample(c(rep(NA, 9), 1:9), 32, TRUE))
keypos(x)
#> [1] 1 1 1 6 1 1 1 9 1 1 1 9 8 8 1 1 1 1 7 1 6 3
#> [23] 10 1 8 4 5 9 1 2 1 1
stopifnot(identical(keypos(x), match.integer64(x, sort(unique(x), na.last=FALSE))))
#> Warning: Detected that 'match.integer64' was called directly. Instead only call 'match' and rely on S3 dispatch. To suppress this warning, e.g. if this is a false positive, use options(bit64.warn.exported.s3.method = FALSE). In the next version, this symbol will stop being exported.