Print number as reduced fraction in R

2020-02-07 19:52发布

问题:

On my old beat-up TI-83 I can get a reduced fraction representation of a rational real number with the following syntax.

.14>Frac
               7/50

Is there a similar syntax, function, or CRAN package that will allow me to do this in R?

回答1:

fractions() in the MASS package does just that:

> library(MASS)
> fractions(.14)
[1] 7/50


标签: r fractions