[Rd] hist( ) fails with 'Inf' values unlike plot( ) (PR#7220)

From: <epurdom_at_stanford.edu>
Date: Fri 10 Sep 2004 - 02:46:34 EST


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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri Sep 10 02:50:41 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:00:14 EST