R: Extract Unique Elements from integer64

unique.integer64 {bit64} | R Documentation

## Extract Unique Elements from integer64

### Description

`unique` returns a vector like `x` but with duplicate elements/rows removed.

### Usage

    ## S3 method for class 'integer64'
    unique(x, incomparables = FALSE, order = c("original","values","any")
    , nunique = NULL, method = NULL, ...)

### Arguments

`x` | a vector or a data frame or an array or `NULL`.
`incomparables` | ignored
`order` | The order in which unique values will be returned, see details
`nunique` | NULL or the number of unique values (including NA). Providing `nunique` can speed-up matching when `x` has no cache. Note that a wrong nunique can cause undefined behaviour up to a crash.
`method` | NULL for automatic method selection or a suitable low-level method, see details
`...` | ignored

### Details

This function automatically chooses from several low-level functions considering the size of `x` and the availability of a cache. Suitable methods are `hashmapuni` (simultaneously creating and using a hashmap) , `hashuni` (first creating a hashmap then using it) , `sortuni` (fast sorting for sorted order only) , `sortorderuni` (fast ordering for original order only) and `orderuni` (memory saving ordering).
The default `order="original"` returns unique values in the order of the first appearance in `x` like in `unique`, this costs extra processing. `order="values"` returns unique values in sorted order like in `table`, this costs extra processing with the hash methods but comes for free. `order="any"` returns unique values in undefined order, possibly faster. For hash methods this will be a quasi random order, for sort methods this will be sorted order.

### Value

For a vector, an object of the same type of `x`, but with only one copy of each duplicated element. No attributes are copied (so the result has no names).

### Author(s)

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

### See Also

`unique` for the generic, `unipos` which gives the indices of the unique elements and `table.integer64` which gives frequencies of the unique elements.

### Examples

    x <- as.integer64(sample(c(rep(NA, 9), 1:9), 32, TRUE))
    unique(x)
    unique(x, order="values")

    stopifnot(identical(unique(x),  x[!duplicated(x)]))
    stopifnot(identical(unique(x),  as.integer64(unique(as.integer(x)))))
    stopifnot(identical(unique(x, order="values")
    ,  as.integer64(sort(unique(as.integer(x)), na.last=FALSE))))

[Package bit64 version 0.9-7 Index]