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

Martin Maechler Martin Maechler <maechler@stat.math.ethz.ch>
Fri, 25 Sep 1998 17:21:22 +0200


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

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

looks like

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

which is pretty ugly.

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

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

---
S gives something like

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

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

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

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

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

---------------

What do we ( you !) want ?

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