ripley@stats.ox.ac.uk
2005-Dec-11 04:35 UTC
[Rd] (PR#8376 inconsistency between plot(hist(...)) and hist(...)
On Sun, 11 Dec 2005 clausen at econ.upenn.edu wrote:> Full_Name: Andrew Clausen > Version: 2.1.0 > OS: Debian GNU/Linux > Submission from: (NULL) (71.242.192.73) > > > Hi, > > When I type > > hist(x, freq=F) > > I get a density function, as I expect. However, if I type > > plot(hist(x, freq=F)) > > then I get the same output as if I had typed: > > hist(x, freq=T) > > I expect that the second command should have the same semantics as the first.And it actually does, but your usage does not. Did you check the help page? ?plot.histogram shows plot.histogram has a 'freq' argument, and the correct usage is plot(hist(x), freq=FALSE) -- 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
clausen@econ.upenn.edu
2005-Dec-11 07:40 UTC
[Rd] (PR#8376 inconsistency between plot(hist(...)) and hist(...)
Hi Brian, On Sun, Dec 11, 2005 at 04:34:50AM +0000, Prof Brian Ripley wrote:> Did you check the help page? ?plot.histogram shows plot.histogram has a > 'freq' argument, and the correct usage is > > plot(hist(x), freq=FALSE)Ah, thanks for the explanation. I didn't occur to me to check the plot.histogram() help page. Besides, even if I had read it, I still don't think the semantics would have been clear to me without additional experimentation. Perhaps it might be helpful to document in the hist() help page which attributes are stored in the hist() object. Alternatively/additionally, hist() could emit a warning or error if plot=FALSE and irrelevant (non-stored) attributes are set. Cheers, Andrew