# subset: Subset a histogram by removing some of the buckets. In HistogramTools: Utility Functions for R Histograms

## Description

SubsetHistogram creates a histogram by zooming in on a portion of a larger histogram and discarding tail buckets.

## Usage

 `1` ``` SubsetHistogram(x, minbreak=NULL, maxbreak=NULL) ```

## Arguments

 `x` A histogram object (created by `hist`). `minbreak` If non-`NULL`, specifies a new minimum breakpoint for the returned histogram. Must be one of the existing breakpoints of `x`. `maxbreak` If non-`NULL`, specifies a new maximum breakpoint for the returned histogram. Must be one of the existing breakpoints of `x`.

## Details

This function provides a way to "zoom-in" on a histogram by setting new minimum and maximum breakpoints and returning a histogram of only the interior part of the distribution. At least one of `minbreak` or `maxbreak` should be set, otherwise the original histogram is returned unmodified.

## Author(s)

`histogramtools-package` and `hist`.

## Examples

 ```1 2 3 4 5``` ```hist.1 <- hist(c(1,2,3), breaks=c(0,1,2,3,4,5,6,7,8,9), plot=FALSE) hist.2 <- SubsetHistogram(hist.1, maxbreak=6) hist.1 hist.2 ```

### Example output

```\$breaks
[1] 0 1 2 3 4 5 6 7 8 9

\$counts
[1] 1 1 1 0 0 0 0 0 0

\$density
[1] 0.3333333 0.3333333 0.3333333 0.0000000 0.0000000 0.0000000 0.0000000
[8] 0.0000000 0.0000000

\$mids
[1] 0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5

\$xname
[1] "c(1, 2, 3)"

\$equidist
[1] TRUE

attr(,"class")
[1] "histogram"
\$breaks
[1] 0 1 2 3 4 5 6

\$counts
[1] 1 1 1 0 0 0

\$density
[1] 0.3333333 0.3333333 0.3333333 0.0000000 0.0000000 0.0000000

\$mids
[1] 0.5 1.5 2.5 3.5 4.5 5.5

\$xname
[1] "c(1, 2, 3)"

\$equidist
[1] TRUE

attr(,"class")
[1] "histogram"
```

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