Given a string or a fraction parsed using parse_fraction()
, this
function will check to see whether it is in its improper form, and
if not, it will convert it to an improper fraction.
as_improper(fraction)
fraction | The input fraction, already parsed, or a string to
be parsed using |
---|
frac <- "-3 1/2" as_improper(frac)#> [1] "-7/2"p_frac <- parse_fraction(frac, improper = FALSE) as_improper(p_frac)#> [1] "-7/2"as_improper("3")#> [1] "3/1"