HistogramTools (version 0.3.2)

trimsparse: Trim the tails of a sparse histogram.

Description

Removes empty consecutive buckets at the tails of a histogram.

Usage

TrimHistogram(x, left=TRUE, right=TRUE)

Arguments

x
A histogram object (created by hist).
left
If TRUE, consecutive buckets in the left tail of the histogram without any elements will be removed from the returned histogram.
right
If TRUE, consecutive buckets in the right tail of the histogram without any elements will be removed from the returned histogram.

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 one with fewer buckets by removing sparseness in the tails.

See Also

histogramtools-package and hist.

Examples

Run this code
hist.1 <- hist(c(1,2,3), breaks=c(0,1,2,3,4,5,6,7,8,9), plot=FALSE)
length(hist.1$counts)
sum(hist.1$counts)
hist.trimmed <- TrimHistogram(hist.1)
length(hist.trimmed$counts)
sum(hist.trimmed$counts)

Run the code above in your browser using DataLab