Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

keypos

Extract Positions in redundant dimension table


Description

keypos returns the positions of the (fact table) elements that participate in their sorted unique subset (dimension table)

Usage

keypos(x, ...)
## S3 method for class 'integer64'
keypos(x, method = NULL, ...)

Arguments

x

a vector or a data frame or an array or NULL.

method

NULL for automatic method selection or a suitable low-level method, see details

...

ignored

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) and orderkey (memory saving ordering).

Value

an integer vector of the same length as codex containing positions relativ to codesort(unique(x), na.last=FALSE)

Author(s)

Jens Oehlschlägel <Jens.Oehlschlaegel@truecluster.com>

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)

stopifnot(identical(keypos(x),  match.integer64(x, sort(unique(x), na.last=FALSE))))

bit64

A S3 Class for Vectors of 64bit Integers

v4.0.5
GPL-2 | GPL-3
Authors
Jens Oehlschlägel [aut, cre], Leonardo Silvestri [ctb]
Initial release
2020-08-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.