[R] Normal behavior or bug?

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Sat Mar 23 21:15:57 CET 2002


On Sat, 23 Mar 2002, Marc Feldesman wrote:

>  >selectiris<-sample(1:5, 150, replace=T)
>  > hist(selectiris, plot=TRUE) #freq=TRUE, breaks=5, etc all do the same thing
>  >truehist(selectiris)
>
> Is the behavior of "hist" in this sample of code correct.  On my system
> (Windows 2K, SP2) the first and second bars are pushed together, while the
> 3rd, 4th, and 5th bars are correctly positioned.
>
> The function "truehist" gives the correct representation of the data.
>
> Am I missing an option in hist or is there a bug?

Neither.  It's a design feature.  Those spaces are empty bins. If you use
right=FALSE you will get a different pattern.

The default bins are [1, 1.5], (1.5, 2], (2, 2.5] ....
and your data are integers, so (2, 2.5] is empty.

This is one of the quirks that truehist() was designed to avoid.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list