On Nov 28, 2007 12:32 AM, Deepayan Sarkar <[EMAIL PROTECTED]> wrote: > > According to the Sturges rule, the number of classes of a histogram is > > the closest integer to > > > > 1 + logb(n,base=2) > > > > where n is the number of observations. The function hist(), by > > default, uses the Sturges rule. However, the code > > > > x <- 1:200 > > hist(x) > > > > produces a histogram with 10 classes and not 9 classes as determined > > by the Sturges rule. What am I missing? > > The documentation does say that: > > In the last three cases the number is a suggestion only. > > Basically, hist() uses "pretty" breakpoints, and you have > > > pretty(c(1, 200), 9) > [1] 0 20 40 60 80 100 120 140 160 180 200 > > (i.e. 10 intervals even when you ask for 9). truehist() in MASS and > histogram() in lattice don't have this "feature" (though truehist > doesn't seem to allow "Sturges" as an option).
Thanks, Deepayan, for the clarification. Paul ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.