Learn R Programming

HistogramTools (version 0.3.2)

quantile: Histogram Approximate Quantiles.

Description

Approximate the quantiles of the underlying distribution for which only a histogram is available.

Usage

ApproxQuantile(x, probs, ...) ApproxMean(x) Count(x)

Arguments

x
A histogram object (created by hist).
probs
Numeric vector of probabilities with values in [0,1].
...
Any other arguments to pass to wtd.quantile.

Details

Many data analysis pipelines write out histogram protocol buffers with thousands of buckets so as to be applicable in a wide range of contexts. This function provides a way to transform the histogram into approximations of the quantile, median, mean, etc of the underlying distribution. Count(x) returns the number of observations in the histogram.

See Also

histogramtools-package and hist.

Examples

Run this code
x <- hist(c(1,2,3), breaks=c(0,1,2,3,4,5,6,7,8,9), plot=FALSE)
Count(x)
ApproxMean(x)
ApproxQuantile(x, .5)
ApproxQuantile(x, c(.05, .95))

Run the code above in your browser using DataLab