breaks_on_nBins {xcms} | R Documentation

## Generate breaks for binning

### Description

Calculate breaks for same-sized bins for data values from `fromX` to `toX`.

### Usage

    breaks_on_nBins(fromX, toX, nBins, shiftByHalfBinSize = FALSE)

### Arguments

`fromX` | numeric(1) specifying the lowest value for the bins.
`toX` | numeric(1) specifying the largest value for the bins.
`nBins` | numeric(1) defining the number of bins.
`shiftByHalfBinSize` | Logical indicating whether the bins should be shifted left by half bin size. This results centered bins, i.e. the first bin being centered at `fromX` and the last around `toX`.

### Details

This generates bins such as a call to `seq(fromX, toX, length.out = nBins)` would. The first and second element in the result vector thus defines the lower and upper boundary for the first bin, the second and third value for the second bin and so on.

### Value

A numeric vector of length `nBins + 1` defining the lower and upper bounds of the bins.

### Author(s)

Johannes Rainer

### See Also

`binYonX` for a binning function.

Other functions to define bins: `breaks_on_binSize`

### Examples

    ## Create breaks to bin values from 3 to 20 into 20 bins
    breaks_on_nBins(3, 20, nBins = 20)
    ## The same call but using shiftByHalfBinSize
    breaks_on_nBins(3, 20, nBins = 20, shiftByHalfBinSize = TRUE)

[Package xcms version 3.0.2 Index]