View source: R/functions-binning.R
breaks_on_nBins | R Documentation |
Calculate breaks for same-sized bins for data values
from fromX
to toX
.
breaks_on_nBins(fromX, toX, nBins, shiftByHalfBinSize = FALSE)
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 |
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.
A numeric vector of length nBins + 1
defining the lower and
upper bounds of the bins.
Johannes Rainer
binYonX
for a binning function.
Other functions to define bins: breaks_on_binSize
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.