Learn R Programming

ppgmmga (version 1.3)

nclass.numpy: Compute the Number of Classes for a Histogram

Description

Compute the number of classes for a histogram as the maximum of the "Sturges" and "FD" (Freedman Diaconis) estimators as in numpy library for Python.

Usage

nclass.numpy(x, ...)

Arguments

x

A vector of values.

...

Further arguments passed to or from other methods.

Author

Scrucca L. luca.scrucca@unipg.it

See Also

Examples

Run this code
if (FALSE) {
library(ggplot2)
x <- rnorm(100)
ggplot() + geom_histogram(aes(x), col = "grey92", bins = nclass.numpy(x))
x <- rnorm(1000)
ggplot() + geom_histogram(aes(x), col = "grey92", bins = nclass.numpy(x))
n = c(50, seq(100,1000,by=100))
brks = rep(NA, length(n))
for(i in seq(n)) brks[i] = nclass.numpy(rnorm(n[i]))
ggplot() + geom_point(aes(x = n, y = brks))
}

Run the code above in your browser using DataLab