trimsparse: Trim the tails of a sparse histogram.

Description Usage Arguments Details Author(s) See Also Examples

Description

Removes empty consecutive buckets at the tails of a histogram.

Usage

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

Author(s)

Murray Stokely mstokely@google.com

See Also

histogramtools-package and hist.

Examples

1
2
3
4
5
6
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)

Example output

[1] 9
[1] 3
[1] 3
[1] 3

HistogramTools documentation built on May 2, 2019, 1:08 p.m.