View source: R/functions-binning.R

breaks_on_binSize | R Documentation |

Defines breaks for `binSize`

sized bins for values ranging
from `fromX`

to `toX`

.

breaks_on_binSize(fromX, toX, binSize)

`fromX` |
numeric(1) specifying the lowest value for the bins. |

`toX` |
numeric(1) specifying the largest value for the bins. |

`binSize` |
numeric(1) defining the size of a bin. |

This function creates breaks for bins of size `binSize`

. The
function ensures that the full data range is included in the bins, i.e. the
last value (upper boundary of the last bin) is always equal `toX`

. This
however means that the size of the last bin will not always be equal to the
desired bin size.
See examples for more details and a comparisom to R's `seq`

function.

A numeric vector defining the lower and upper bounds of the bins.

Johannes Rainer

`binYonX`

for a binning function.

Other functions to define bins:
`breaks_on_nBins()`

## Define breaks with a size of 0.13 for a data range from 1 to 10: breaks_on_binSize(1, 10, 0.13) ## The size of the last bin is however larger than 0.13: diff(breaks_on_binSize(1, 10, 0.13)) ## If we would use seq, the max value would not be included: seq(1, 10, by = 0.13) ## In the next example we use binSize that leads to an additional last bin with ## a smaller binSize: breaks_on_binSize(1, 10, 0.51) ## Again, the max value is included, but the size of the last bin is < 0.51. diff(breaks_on_binSize(1, 10, 0.51)) ## Using just seq would result in the following bin definition: seq(1, 10, by = 0.51) ## Thus it defines one bin (break) less.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.