[R] pretty not pretty

David Brahm brahm at alum.mit.edu
Tue Oct 29 16:31:17 CET 2002

Ott Toomet <otoomet at econ.au.dk> wrote:
> Pretty (R 1.5.1) has problems with zero: 
  > pretty(smallch) 
  [1] -2.000000e-02 -3.469447e-18 2.000000e-02 4.000000e-02 6.000000e-02 
  [6] 8.000000e-02 1.000000e-01 1.200000e-01 
> You notice -3.46e-18 instead of 0. Is this feature changed in 1.6.0, 
> or are there any simple ways to get around of it? 

I mentioned this in R-devel on June 14, 2002 ("pretty() sometimes isn't").  It
derives from the roundoff error introduced in seq(-.02, .12, length=8).  I
suggested that the last line of the code for pretty() should get a zapsmall()
around it:
  pretty <- function(...) {
    zapsmall(seq(z$l, z$u, length = z$n + 1))

Since that hasn't been implemented, you could simply put a zapsmall() around
every pretty() in your code.
                              -- David Brahm (brahm at alum.mit.edu)
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list