breaks | R Documentation |
Creates a numeric vector of break points for the given data x
.
The resulting breaks define bins that are either equidistant (fixed width)
or non-equidistant (quantile-based). If width
is not specified, it defaults
to diff(pretty(x))[1]
. The probs
argument can either be a single
integer, specifying the number of quantiles, or a numeric vector of probabilities
in the interval [0, 1]
.
breaks(x, width = NULL, probs = NULL)
add_breaks(x, width = NULL, probs = NULL)
dbreaks(x, width = NULL, probs = NULL)
x |
numeric vector: the data to compute breaks for. |
width |
numeric, optional: desired bin width (default: |
probs |
numeric, optional: number of quantiles (single integer) or
vector of probabilities in |
If probs
is used, break points are rounded to the nearest multiple of width
.
Duplicates are removed, and the range is extended if necessary to include the
full range of x
.
A numeric vector containing the break points.
x <- rnorm(100, mean = 1.8, sd = 0.1)
breaks(x) # equidistant bins
breaks(x, width = 0.1) # custom width bins
breaks(x, width = 0.1, probs = 4) # quantile-based bins
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.