qtile: (Q)uan(Tile)s

View source: R/highlevel64.R

qtileR Documentation

(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 class 'integer64'
qtile(x, probs = seq(0, 1, 0.25), names = TRUE, method = NULL, ...)
	## S3 method for class 'integer64'
quantile(x, probs = seq(0, 1, 0.25), na.rm = FALSE, names = TRUE, type=0L, ...)
	## S3 method for class 'integer64'
median(x, na.rm = FALSE, ...)
 ## S3 method for class 'integer64'
mean(x, na.rm = FALSE, ...)
	## S3 method for class 'integer64'
summary(object, ...)
 ## mean(x, na.rm = FALSE, ...)
 ## or
 ## mean(x, na.rm = FALSE)

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

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).

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.

Author(s)

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

See Also

rank.integer64 for simple ranks and quantile for quantiles.

Examples

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)))))

bit64 documentation built on Sept. 30, 2024, 9:23 a.m.