From ripley at stats.ox.ac.uk  Thu Feb 10 18:11:44 2005
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu Feb 10 18:11:58 2005
Subject: [Rd] hist() error when prob=NULL (PR#7682)
In-Reply-To: <20050210163011.D3450DEEB@slim.kubism.ku.dk>
References: <20050210163011.D3450DEEB@slim.kubism.ku.dk>
Message-ID: <Pine.LNX.4.61.0502101708130.17476@gannet.stats>

According to the help page, freq and prob are logical, so this is 
correctly an error.

What it actually does is

         freq <- if (!missing(probability)) !as.logical(probability)

which is consistent with the documentation.


On Thu, 10 Feb 2005 tomhopper@comcast.net wrote:

> Full_Name: Tom Hopper
> Version: 2.0.1
> OS: Windows 2000
> Submission from: (NULL) (69.220.229.2)
>
>
> While attempting to wrap hist() in my own custom function (for formatting
> purposes), I notice that a call like
>
>   > hist(x, prob=NULL)
>
> produces the output:
>
>   Error in if (freq) x$counts else { : argument is of length zero
>
> Switching to use freq does not produce an error, even when freq = NULL.
>
> It appears that hist() is checking for the condition
>
>   !missing(prob)
>
> but needs to add a check for a NULL value
>
>   && !is.null(prob)

-- 
Brian D. Ripley,                  ripley@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


[Rd] hist() error when prob=NULL (PR#7682)
Prof Brian Ripley