# n.bins

0th

Percentile

##### Number of Bins for Histogram

Several rules for calculating the number of bins to use for a histogram.

Keywords
dplot
##### Usage
n.bins(x, rule=c("freedman.diaconis", "sturges", "scott", "simple"))
##### Arguments
x
numeric vector, variable for histogram
rule
see below.
##### Details

[object Object],[object Object],[object Object],[object Object] where $n$ is the number of observations, $range$ is the range of x, $IQR$ is the inter-quartile range of x, and $s$ is the standard deviation of x.

##### Value

• the number of bins.

##### References

Freedman, D. and Diaconis, P. (1981) On the histogram as a density estimator. Zeitschrift fur Wahrscheinlichkeitstheorie und verwandte Gebiete 57, 453--476. Scott, D. W. (1979) On optimal and data based-histograms. Biometrika 66, 605--610. Venables, W. N. and Ripley, B. D. (1999) Modern Applied Statistics with S-PLUS, Third Edition, Springer.

##### See Also

hist

• n.bins
##### Examples
attach(UN)
n.bins(gdp)
## [1] 19
n.bins(gdp, "sturges")
## [1] 9
n.bins(gdp, "scott")
## [1] 8
n.bins(gdp, "simple")
## [1] 22
hist(gdp)
hist(gdp, nclass=n.bins(gdp))
Documentation reproduced from package car, version 1.2-15, License: GPL (>= 2)

### Community examples

Looks like there are no examples yet.