Description Usage Arguments Value Examples
The as_fraction
function takes a numeric input and converts it to a fraction.
The input is first rounded to the desired level of precision (entered as a
value between 1 and 7).
1 | as_fraction(number, precision = 3, improper = TRUE)
|
number |
The decimal you want to convert to a fraction. |
precision |
The number of digits to round the decimal to before trying to convert the result to a fraction. Must be greater than 1 but less than 8. |
improper |
Logical. Should the fraction be a returned as an improper
fraction or a proper fraction? Defaults to |
A formatted list
printed with print.fraction()
. The list
includes four elements:
whole
: The absolute value of the whole number part of the decimal. This
is NULL
if improper = TRUE
.
numerator
: The numerator of the resulting fraction.
denominator
: The denominator of the resulting fraction.
sign
: -1
if the input is negative; 1
if the input is positive; 0
if the input is zero.
1 2 3 4 | as_fraction(3.2454)
as_fraction(3.2454, 2, TRUE)
as_fraction(3.2454, 2, FALSE)
as_fraction(3.2454, 1, FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.