[R] pretty not pretty

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Wed, 30 Oct 2002 12:21:29 +0100


{R-help -> R-devel  since this becomes too technical fine tuning}

>>>>> "MM" == Martin Maechler <maechler@stat.math.ethz.ch>
>>>>>     on Wed, 30 Oct 2002 11:56:36 +0100 writes:

>>>>> "DavidB" == David Brahm <brahm@alum.mit.edu>
>>>>>     on Tue, 29 Oct 2002 10:31:17 -0500 writes:

    DavidB> Ott Toomet <otoomet@econ.au.dk> wrote:
    >>> Pretty (R 1.5.1) has problems with zero: 
    >>> pretty(smallch) 
    DavidB> [1] -2.00000e-02 -3.469447e-18 2.00000e-02 4.00000e-02 6.00000e-02 
    DavidB> [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? 

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


    DavidB> pretty <- function(...) {
    DavidB> ...
    DavidB> zapsmall(seq(z$l, z$u, length = z$n + 1))
    DavidB> }

    DavidB> Since that hasn't been implemented, you could simply
    DavidB> put a zapsmall() around every pretty() in your code.

    MM> It *) now _has_ been implemented. ---> will be in R-beta tomorrow
    MM> and R 1.6.1.
    MM> Whereas for seq() it is clear that you will see these roundoffs,
    MM> they are ``wrong'' for pretty().

    MM> Thank you David, for the reminder.

    MM> *) I've used  zapsmall(seq(z$l, z$u, length = z$n + 1), digits = 7)
    MM> instead in order to make sure that the result will not depend
    MM> on options("digits").

and now found that "digits = 7" is doing too much in rare cases.
As a matter fact, zapsmall() has been a misnomer ever since it
was created for S/S-plus :
    It rounds all values (as its documentation clearly says!), 
    i.e. is not only zapping the small values as its name suggests.

After my current testing, 
I think I want "digits = 14" (+/- 1 may be).
Martin
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel 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-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._