format(numericmatrix, ...) : proposal for a change

Friedrich Leisch Friedrich.Leisch@ci.tuwien.ac.at
Fri, 25 Sep 1998 17:30:47 +0200 (CEST)


Columnwise formatting would be fine with me ... could you just leave
the current behavior as option? In many cases matrix-wide formatting
is useful!


.f


>>>>> On Fri, 25 Sep 1998 17:21:22 +0200,
>>>>> Martin Maechler (MM) wrote:

MM> Since format, i.e.,  format.default(.), is a pretty basic function I
MM> thought I'd ask  before just changing it...

MM> 	aa <- cbind(1:7, rnorm(7))
MM> 	format(aa)
MM> or
MM> 	format(aa, digits=7)

MM> looks like

MM>       [,1]         [,2]        
MM>  [1,] " 1.0000000" " 0.2406669"
MM>  [2,] " 2.0000000" "-0.4973221"
MM>  [3,] " 3.0000000" " 0.4672260"
MM>  [4,] " 4.0000000" " 0.4794697"
MM>  [5,] " 5.0000000" "-1.0234062"
MM>  [6,] " 6.0000000" "-0.3430790"
MM>  [7,] " 7.0000000" "-0.1847634"

MM> which is pretty ugly.

MM> What I'd rather want is that each column be formatted independently, i.e.,
MM> (almost) the result I'd currently get from

MM> 	apply(aa, 2, format, digits=7)

MM> ---
MM> S gives something like

S> format(aa, digits=7)
MM>                [,1]           [,2] 
MM> [1,] " 1          " " 0.07364329 "
MM> [2,] " 2          " "-0.7101905  "
MM> [3,] " 3          " " 0.005834993"
MM> [4,] " 4          " " 0.3425964  "
MM> [5,] " 5          " " 0.8825893  "
MM> [6,] " 6          " " 0.9540261  "
MM> [7,] " 7          " "-0.4660654  "

MM> (which is different from the above apply(...) by using strings which all
MM>  have the identical number of characters).

MM> Proposal: I'd like to have format(<numeric matrix>, ...) change to do
MM> 	COLUMNWISE formatting, either the way as apply(..) above, or
MM> 	returning strings of identical length (somewhat like S above).

MM> Note  I don't intend to copy S-plus'  ``full mess'' of doing it :
MM> In S-plus  
MM> 	format(aa)
MM> and	format(aa, digits = .Options$digits)
MM> are very different even though .Options$digits *IS* the default for
MM> digits...

MM> Also, we have formatC(.) which very useful for quite a few problems...

MM> ---------------

MM> What do we ( you !) want ?

MM> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
MM> r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
MM> Send "info", "help", or "[un]subscribe"
MM> (in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
MM> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._