[R] format a matrix as fractions?

Michael Friendly friendly at yorku.ca
Tue Dec 31 16:25:08 CET 2013


Is there some way to format a matrix of fractions as fractions?  I think 
I've seen this somewhere,
but search on Rseek came up empty.

Example:

 > outer(1/seq(1:3), 1/seq(1:3))
           [,1]      [,2]      [,3]
[1,] 1.0000000 0.5000000 0.3333333
[2,] 0.5000000 0.2500000 0.1666667
[3,] 0.3333333 0.1666667 0.1111111
 >

should print as

       1     1/2     1/3
     1/2    1/4     1/6
     1/3    1/6     1/9

TIA
-Michael

-- 
Michael Friendly     Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, Quantitative Methods
York University      Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele Street    Web:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA



More information about the R-help mailing list