Fast high-level methods for sorting and ordering. These are wrappers to
ramsort.integer64() and friends and do not modify their arguments.
Usage
# S3 method for class 'integer64'
sort(
x,
decreasing = FALSE,
has.na = TRUE,
na.last = TRUE,
stable = TRUE,
optimize = c("time", "memory"),
VERBOSE = FALSE,
...
)
# S3 method for class 'integer64'
order(
...,
na.last = TRUE,
decreasing = FALSE,
has.na = TRUE,
stable = TRUE,
optimize = c("time", "memory"),
VERBOSE = FALSE
)Arguments
- x
a vector to be sorted by
ramsort.integer64()andramsortorder.integer64(), i.e. the output ofsort.integer64()- decreasing
boolean scalar telling ramsort whether to sort increasing or decreasing
- has.na
boolean scalar defining whether the input vector might contain
NAs. If we know we don't have NAs, this may speed-up. Note that you risk a crash if there are unexpectedNAs withhas.na=FALSE- na.last
boolean scalar telling ramsort whether to sort
NAs last or first. Note that 'boolean' means that there is no third optionNAas insort()- stable
boolean scalar defining whether stable sorting is needed. Allowing non-stable may speed-up.
- optimize
by default ramsort optimizes for 'time' which requires more RAM, set to 'memory' to minimize RAM requirements and sacrifice speed
- VERBOSE
cat some info about chosen method
- ...
further arguments, passed from generics, ignored in methods
Examples
x <- as.integer64(sample(c(rep(NA, 9), 1:9), 32, TRUE))
x
#> integer64
#> [1] 9 <NA> 6 6 <NA> 9 5 3 3 <NA> 1 <NA> 5
#> [14] 9 7 3 5 8 5 <NA> 8 8 1 3 <NA> <NA>
#> [27] <NA> 7 <NA> 7 <NA> <NA>
sort(x)
#> integer64
#> [1] 1 1 3 3 3 3 5 5 5 5 6 6 7
#> [14] 7 7 8 8 8 9 9 9 <NA> <NA> <NA> <NA> <NA>
#> [27] <NA> <NA> <NA> <NA> <NA> <NA>
message("the following has default optimize='time' which is faster but requires more RAM
, this calls 'ramorder'")
#> the following has default optimize='time' which is faster but requires more RAM
#> , this calls 'ramorder'
order.integer64(x)
#> Warning: Detected that 'order.integer64' was called directly. Instead only call 'order' 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.
#> [1] 11 23 8 9 16 24 7 13 17 19 3 4 15 28 30 18 21 22 1 6 14 2
#> [23] 5 10 12 20 25 26 27 29 31 32
message("slower with less RAM, this calls 'ramsortorder'")
#> slower with less RAM, this calls 'ramsortorder'
order.integer64(x, optimize="memory")
#> Warning: Detected that 'order.integer64' was called directly. Instead only call 'order' 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.
#> [1] 11 23 8 9 16 24 7 13 17 19 3 4 15 28 30 18 21 22 1 6 14 2
#> [23] 5 10 12 20 25 26 27 29 31 32