Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print number as reduced fraction in R

Tags:

r

fractions

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?

like image 455
Daniel Standage Avatar asked Feb 18 '11 20:02

Daniel Standage


People also ask

How do I turn a decimal into a fraction in R?

Data Visualization using R Programming In R, we can use fractions function of MASS package to convert a decimal value or a vector of decimal values to fractional form. To do so, we just need to pass the value in fractions function as fractions(“Decimal_value or Vector_Of_Decimal_Values”).

What is 2.666666 as a fraction?

Well remember that above, x was originally set equal to 2.666666 via x=2.666666, and now we have that x is also equal to 24/9, so that means 2.666666=24/9..and there's 2.666666 written as a fraction!


1 Answers

fractions() in the MASS package does just that:

> library(MASS) > fractions(.14) [1] 7/50 
like image 118
Fojtasek Avatar answered Sep 28 '22 19:09

Fojtasek