[Rd] Strange formatting

Prof Brian D Ripley ripley@stats.ox.ac.uk
Wed, 16 May 2001 20:59:25 +0100 (BST)


On Wed, 16 May 2001, Duncan Murdoch wrote:

> I've never noticed this before, though it's probably not new.  In
> 1.2.3 for Windows, if I print a short vector the formatting is
> different than if I print a long one, whether or not they fit on one
> line.  The short/long split appears to be between 9 and 10 elements:
>
>  > 1:9
>  [1] 1 2 3 4 5 6 7 8 9
>  > 1:10
>   [1]  1  2  3  4  5  6  7  8  9 10
>
>  > sqrt(1:9)
>  [1] 1.000000 1.414214 1.732051 2.000000 2.236068 2.449490 2.645751
> 2.828427
>  [9] 3.000000
>  > sqrt(1:10)
>   [1] 1.000000 1.414214 1.732051 2.000000 2.236068 2.449490 2.645751
> 2.828427
>   [9] 3.000000 3.162278
>
>
> The spacing between the integer values is different, and there's a
> space before the "[1]" in the longer vectors.
>
> Is this intentional?  What's the reasoning for this difference?

I guess so.  For the first, the elements will line up:

> options(width=40)
> 1:50
 [1]  1  2  3  4  5  6  7  8  9 10 11 12
[13] 13 14 15 16 17 18 19 20 21 22 23 24
[25] 25 26 27 28 29 30 31 32 33 34 35 36
[37] 37 38 39 40 41 42 43 44 45 46 47 48
[49] 49 50

and that shows you the reason for the space too.

FWIW, S-PLUS 3.4 does the same things.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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