# [Rd] a fault in the "hist" - function (PR#6931)

ligges at statistik.uni-dortmund.de ligges at statistik.uni-dortmund.de
Wed Jun 2 15:34:46 CEST 2004

```stephanschlueter at gmx.de wrote:

> Full_Name: Stephan Schlueter
> Version: 1.9.0
> OS:
> Submission from: (NULL) (217.184.109.24)
>
>
> During my studies, I found a fault in the hist()-function:
> If you have a vector x with values around zero and also bigger than 10,000,000 ,
> there will be a shift of   -max(x)/10,000,000    in the hist-datas.
> See my example:
>
> x<-runif(10000)
> hist(x,breaks=c(seq(-3,3,0.1)),prob=TRUE)
> #everything ok, but now produce the problem
> x=20000000
> hist(x,breaks=c(seq(-3,3,0.1),max(x)),prob=TRUE,xlim=c(-3,3))
> #here you can see the shift
>
> hist(x + max(x)/10000000,breaks=c(seq(-3,3,0.1),max(x)),prob=TRUE,xlim=c(-3,3))
> #first solution (but I don't know ,why it works)
>
> for(i in 1:10000)
>  {
>  if(x[i]>10)x[i]=10
>  }
> hist(x,breaks=c(seq(-3,3,0.1),max(x)),prob=TRUE,xlim=c(-3,3))
> #second solution (the better one I think)
>
>
> Good Luck for the solution of this problem, and it would be nice to send me an
>                Thanks and till then,  Stephan Schlueter
>
> ______________________________________________
> R-devel at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel

The problem is in hist.default():

diddle <- 1e-7 * max(abs(range(breaks)))

and whereever we are diddling - there are some disadvantages.

Do we want a flag that turns off diddling and the following "fuzz"
stuff? Or do we want something to adjust the hardcoded heuristical value
"1e-7" (to zero, for example)?

Uwe Ligges

```