[Rd] hist( ) fails with 'Inf' values unlike plot( ) (PR#7220)
Prof Brian Ripley
ripley at stats.ox.ac.uk
Thu Sep 9 21:29:57 CEST 2004
One problem here is pretty() which should accept non-finite values as it
does in S. It will in 2.0.0.
It is easiest to change !is.na to is.finite, which is what some plot()
methods use.
On Thu, 9 Sep 2004 epurdom at stanford.edu wrote:
> Full_Name: Elizabeth Purdom
> Version: 1.9.1
> OS: Windows
> Submission from: (NULL) (171.64.102.192)
>
>
> hist() fails if encounters 'Inf' value, rather than giving warning and removing.
> Other graphics, like plot(), don't have this problem. It's actually rather
> confusing if you are taking the log of data real valued data with a few
> non-positive numbers. hist() works fine in this situation unless you happen to
> have an exact 0, as oppose to just negative numbers. Then log(0)=Inf while
> log(-1)=NA and NA values are removed by the program while Inf kills it. At least
> a better error message would be good, because as it is, it looks like the
> program can't handle NAs.
>
> > x<-seq(-5,100,by=1)
> ##Gives error, no output
> > hist(log(x))
> Error in pretty(range(x), n = breaks, min.n = 1) :
> NA/NaN/Inf in foreign function call (arg 1)
> In addition: Warning message:
> NaNs produced in: log(x)
> ##Gives log() warning
> > hist(log(x)[!is.infinite(log(x))])
> Warning messages:
> 1: NaNs produced in: log(x)
> 2: NaNs produced in: log(x)
>
> ______________________________________________
> R-devel at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
--
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
More information about the R-devel
mailing list