Re: [R] histogram

From: <Bill.Venables_at_csiro.au>
Date: Fri, 16 May 2008 16:40:23 +1000

This is pretty important.

With freq = TRUE the y-axis label is "Frequency" and the heights of the panels are equal to the frequency of the panel. However as the panel widths you have requested are unequal, this implies that the *areas* of the panels, the really important bit, cannot be proportional to the relative frequency. With equal class widths this can still happen if the heights are equal to the absolute frequency.

With freq = FALSE, the y-axis label is "Density", and all is well. Areas are now actually equal to relative frequencies, and no one expects heights to be. This is why the message is telling you "Well, if you want unequal class intervals, don't also ask for panel heights to be equal to frequency or the histogram will become misleading."

Basically R is reluctant to let you shoot yourself in the foot unless you are really determined to do so.

Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA -----Original Message-----
From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] On Behalf Of Roslina Zakaria Sent: Friday, 16 May 2008 4:12 PM
To: R help forum
Subject: [R] histogram

Hi r-expert,
I would like to plot histogram using frequency not density. But I got the following warning.
 obs.hist <- hist(jan_data2[,4],right=FALSE,breaks=c(0,5,10,15,20,100),freq=TRUE,
+             xlab="Rain amt (mm)",ylim=c(0,3000),
+             main="Frequency of observed, Jan (1901-1990), Pooraka")
Warning message:
In plot.histogram(r, freq = freq1, col = col, border = border, angle = angle,  :   the AREAS in the plot are wrong -- rather use freq=FALSE

I don't really understand the warning message and hope anybody can help me. Thanks in advance for your help.  



R-help_at_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.

R-help_at_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. Received on Fri 16 May 2008 - 06:43:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 16 May 2008 - 07:30:40 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive