[R] histogram

Bill.Venables at csiro.au Bill.Venables at csiro.au
Fri May 16 08:40:23 CEST 2008


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.



More information about the R-help mailing list