HistogramTools (version 0.3.2)

MergeBuckets: Merge adjacent buckets in a histogram to create a new histogram.

Description

Merge adjacent buckets in a histogram and return a new histogram.

Usage

MergeBuckets(x, adj.buckets=NULL, breaks=NULL, FUN=sum)

Arguments

x
A histogram object (created by hist).
adj.buckets
The number of adjacent buckets to merge together.
breaks
If adj.buckets is equal to NULL, then this argument either specifies a vector giving the breakpoints between cells, or a single number giving the total number of cells in the new histogram. The vector of new buckets must have the same range as the original break list. If a single number is provided it must be less than length(x$breaks).
FUN
The user defined function that should be run to merge the counts of adjacent buckets in the 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.

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)
hist.2 <- MergeBuckets(hist.1, adj.buckets=2)

hist.1
hist.2

Run the code above in your browser using DataLab