[Rd] Strange formatting

Peter Dalgaard BSA p.dalgaard@biostat.ku.dk
16 May 2001 21:31:14 +0200


Duncan Murdoch <murdoch@stats.uwo.ca> writes:

> 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?

The spacing is to print all elements in the same field width, and 10
wouldn't look good in a field of with 2. I don't think that could be
much different (compare 1:100 and 1:99). The labels would seem to be
generated to make room for the label with the longest possible width,
which is slightly botched since that width need not be used by any of
the labels. Submit a patch?

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._