These methods are packaged here for methods in packages bit64 and ff.
is.sorted returns a logical scalar, the other methods return an integer scalar.
All these functions benefit from a sortcache(), ordercache() or
sortordercache(). na.count(), nvalid() and nunique() also
benefit from a hashcache().
na.count(integer64): returns the number of NAs
nvalid(integer64): returns the number of valid data points,
usually length() minus na.count.
is.sorted(integer64): checks for sortedness of x (NAs sorted first)
nunique(integer64): returns the number of unique values
nties(integer64): returns the number of tied values.
If a cache() exists but the desired value is not cached, then these
functions will store their result in the cache. We do not consider this
a relevant side-effect, since these small cache results do not have a
relevant memory footprint.
cache() for caching functions and sortordercache() for functions creating big caches
x <- as.integer64(sample(c(rep(NA, 9), 1:9), 32, TRUE))
length(x)
#> [1] 32
na.count(x)
#> [1] 14
nvalid(x)
#> [1] 18
nunique(x)
#> [1] 9
nties(x)
#> [1] 30
table.integer64(x)
#> x
#> <NA> 1 2 3 4 5 7 8 9
#> 14 3 3 1 1 2 3 3 2
x
#> integer64
#> [1] <NA> <NA> 2 3 1 9 2 8 8 <NA> <NA> 7 1 7 <NA>
#> [16] 5 4 <NA> 1 <NA> <NA> <NA> <NA> 9 5 7 <NA> <NA> <NA> 2
#> [31] 8 <NA>