From Martin Maechler <maechler@stat.math.ethz.ch>  Wed Oct 30 11:21:29 2002
From: Martin Maechler <maechler@stat.math.ethz.ch> (Martin Maechler)
Date: Wed, 30 Oct 2002 12:21:29 +0100
Subject: [R] pretty not pretty
In-Reply-To: <15807.47844.122831.475588@gargle.gargle.HOWL>
References: <15806.43461.675233.576774@gargle.gargle.HOWL>
 <15807.47844.122831.475588@gargle.gargle.HOWL>
Message-ID: <15807.49337.25761.585343@gargle.gargle.HOWL>

{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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[R] pretty not pretty
Martin Maechler