[Rd] histogram of frequencies (PR#861)

bernd.winkler@genedata.com bernd.winkler@genedata.com
Mon, 5 Mar 2001 15:01:55 +0100 (MET)

Full_Name: Dr. Bernd Winkler
Version: 1.2.2
OS: Linux
Submission from: (NULL) (

Hi all,

having updated to version 1.2.2 last week I experienced some strange behaviour
the hist function.

I want to plot a histogram of frequencies resp. counts, for example poisson 
random numbers, on a predefined and fixed x scale

> hist(rpois(500, 2), breaks=0:10)

But instead of the frequencies I get the density of these data.
Introducing the parameter freq=TRUE then I get the frequencies but 
with the following warning message

> hist(rpois(500, 2),breaks=0:10, freq=TRUE)
Warning message: 
the AREAS in the plot are wrong -- rather use `freq=FALSE'! in:
plot.histogram(r, freq = freq, col = col, border = border, main = main,  

The following excerpt from hist.default(...) (new in 1.2.2) might have caused
this behaviour:
    diddle <- 1e-07 * max(abs(range(breaks)))
    fuzz <- if (right) 
        c(if (include.lowest) -diddle else diddle, rep(diddle, 
            length(breaks) - 1))
    else c(rep(-diddle, length(breaks) - 1), if (include.lowest) diddle else
    breaks <- breaks + fuzz

The addition of the fuzz variable to the breaks causes hist 
to think of no equidistant breaks (even if they are) and therefore 
a density plot is generated by default. Removing these lines the 
behaviour is like the one in version 1.2.1 and earlier. 
Is there an alternative doing this with the new version?
And what about the border color parameter in barplot?

Many thanks in advance


r-devel 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-devel-request@stat.math.ethz.ch