Learn R Programming

bit64 (version 4.5.2)

qtile: (Q)uan(Tile)s

Description

Function prank.integer64 projects the values [min..max] via ranks [1..n] to [0..1]. qtile.ineger64 is the inverse function of 'prank.integer64' and projects [0..1] to [min..max].

Usage

qtile(x, probs=seq(0, 1, 0.25), ...)
	# S3 method for integer64
qtile(x, probs = seq(0, 1, 0.25), names = TRUE, method = NULL, ...)
	# S3 method for integer64
quantile(x, probs = seq(0, 1, 0.25), na.rm = FALSE, names = TRUE, type=0L, ...)
	# S3 method for integer64
median(x, na.rm = FALSE, ...)
 # S3 method for integer64
mean(x, na.rm = FALSE, ...)
	# S3 method for integer64
summary(object, ...)
 ## mean(x, na.rm = FALSE, ...)
 ## or
 ## mean(x, na.rm = FALSE)

Value

prank returns a numeric vector of the same length as x.


qtile returns a vector with elements from x

at the relative positions specified by probs.

Arguments

x

a integer64 vector

object

a integer64 vector

probs

numeric vector of probabilities with values in [0,1] - possibly containing NAs

names

logical; if TRUE, the result has a names attribute. Set to FALSE for speedup with many probs.

type

an integer selecting the quantile algorithm, currently only 0 is supported, see details

method

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

na.rm

logical; if TRUE, any NA and NaN's are removed from x before the quantiles are computed.

...

ignored

Author

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

Details

Functions quantile.integer64 with type=0 and median.integer64 are convenience wrappers to qtile.
Function qtile behaves very similar to quantile.default with type=1 in that it only returns existing values, it is mostly symetric but it is using 'round' rather than 'floor'.
Note that this implies that median.integer64 does not interpolate for even number of values (interpolation would create values that could not be represented as 64-bit integers).
This function automatically chooses from several low-level functions considering the size of x and the availability of a cache. Suitable methods are sortqtl (fast sorting) and orderqtl (memory saving ordering).

See Also

rank.integer64 for simple ranks and quantile for quantiles.

Examples

Run this code
x <- as.integer64(sample(c(rep(NA, 9), 1:9), 32, TRUE))
qtile(x, probs=seq(0, 1, 0.25))
quantile(x, probs=seq(0, 1, 0.25), na.rm=TRUE)
median(x, na.rm=TRUE)
summary(x)

x <- x[!is.na(x)]
stopifnot(identical(x,  unname(qtile(x, probs=prank(x)))))

Run the code above in your browser using DataLab