[R] format a matrix as fractions?

Bert Gunter gunter.berton at gene.com
Tue Dec 31 16:35:32 CET 2013


I find that google is usually a better search engine for R topics

Google on "R fractions".

(I got, e.g.
http://stackoverflow.com/questions/5046026/print-number-as-reduced-fraction-in-r
)

-- Cheers,

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch




On Tue, Dec 31, 2013 at 7:25 AM, Michael Friendly <friendly at yorku.ca> wrote:
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list