[R] pretty not pretty

Martin Maechler maechler at stat.math.ethz.ch
Wed Oct 30 11:56:36 CET 2002


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

    DavidB> Ott Toomet <otoomet at 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.

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

Thank you David, for the reminder.

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

Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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