histwidth | R Documentation |
Generates a set of class breaks and absolute frequencies for the range from from
to to
.
Class widths are randomly sampled from the vector widths
. The total number of classes
(nb
) must be an integer multiple of min(widths)
; otherwise, the function stops with an error.
If the initial frequencies (n
) are too small, they can be scaled by an integer factor.
The routine also checks whether the resulting class densities are terminating decimals.
histwidth(from, to, widths, dmax = 2000, maxit = 1000)
width_breaks(from, to, widths, dmax = 2000, maxit = 1000)
dhistwidth(from, to, widths, dmax = 2000, maxit = 1000)
from |
numeric: start value of the range. |
to |
numeric: end value of the range. |
widths |
numeric: vector of possible class widths to sample from. |
dmax |
numeric: maximum denominator allowed when checking fractional densities, see |
maxit |
integer: maximum number of iterations when attempting to find a suitable break pattern. |
A list containing:
breaks |
Numeric vector of class boundaries. |
n |
Integer vector of absolute frequencies for each class. |
decimal |
Logical, |
density |
Numeric vector of class densities. |
l <- histwidth(1.6, 2.1, widths = c(0.05, 0.1, 0.15, 0.2))
x <- histx(l$breaks, l$n)
histdata(x, l$breaks)
# Fallback: use constant min(widths) if no valid break pattern
# is found within max iterations
l <- histwidth(1.6, 2.1, widths=0.05, dmax=10)
str(l)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.