s-news
[Top] [All Lists]

Re: [S] Curious behaviour of print

To: molinari@kispi.unizh.ch
Subject: Re: [S] Curious behaviour of print
From: Martin Maechler <maechler@stat.math.ethz.ch>
Date: Wed, 28 Apr 1999 17:36:56 +0200
Cc: s-news@wubios.wustl.edu
In-reply-to: <99Apr28.145832gmt+0100.1578@gateway.kispizh.unizh.ch> (molinari@kispi.unizh.ch)
References: <99Apr28.145832gmt+0100.1578@gateway.kispizh.unizh.ch>
Reply-to: Martin Maechler <maechler@stat.math.ethz.ch>
Sender: owner-s-news@wubios.wustl.edu
>>>>> "Luciano" == Luciano Molinari <molinari@kispi.unizh.ch> writes:

    Luciano> I have come across a curious phenomenon, which I had not
    Luciano> noticed before. It seems that print behaves differently,
    Luciano> whether a vector as names or not (this adds to other, more
    Luciano> annoying, differences between named and unnamed vectors, such
    Luciano> as the result of is.vector).  

    Luciano> S+> options(digits=3)
    Luciano> S+> zz1_sort(rnorm(10))
    Luciano> S+> zz1
    Luciano> [1] -2.4296 -0.8966 -0.5614 -0.5177 -0.0236  0.1401  0.4715  
0.6122  0.8082
    Luciano> 1.7956
    Luciano> S+> names(zz1)_LETTERS[seq(10)]
    Luciano> S+> zz1
    Luciano> A      B      C      D       E    F     G     H     I   J 
    Luciano> -2.43 -0.897 -0.561 -0.518 -0.0236 0.14 0.471 0.612 0.808 1.8
    Luciano> -----------------

    Luciano> It appears that, with names, each component is individually
    Luciano> printed to 3 significant digits (although in this case I would
    Luciano> prefer F=0.140 and J=1.80), while, without names, the whole
    Luciano> vector is adjusted to the smallest component.  Any comment?

Yes, ``once you know it'' it a piece of cake...

Seriously:

  Named vector are printed with the same functions as are matrices.
  For matrices it makes much sense to format the columns separately..
  -- that's all.

Of course, one could have devised things differently, (such as R did..)

Martin Maechler <maechler@stat.math.ethz.ch>    http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum SOL G1;     Sonneggstr.33
ETH (Federal Inst. Technology)  8092 Zurich     SWITZERLAND
phone: x-41-1-632-3408          fax: ...-1086                   <><
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>