Description Usage Arguments Value Note Examples
When provided a string representing a fraction, parse_fraction
will parse
the provided string to create a list
with the class fraction
applied to
it. This will allow the parsed fraction to be used in subsequent calculations.
1 | parse_fraction(string, improper = TRUE, reduce = TRUE)
|
string |
The input character to be parsed. |
improper |
Logical. Should the result be kept as an improper fraction?
Defaults to |
reduce |
Logical. Should unreduced fractions be simplified? 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 0
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.
The string can be entered either as an improper fraction
(for example, "5/2"
) or as a simplified fraction (for example,
"2 1/2"
). Depending on how it is entered, the resulting list
will have a value in "whole"
or "whole"
will be NULL
.
1 2 3 4 5 6 7 8 9 10 11 | parse_fraction("4/4")
parse_fraction("4/4", reduce = FALSE)
parse_fraction("32/4")
parse_fraction("34/4", reduce = FALSE)
parse_fraction("34/4", reduce = TRUE)
parse_fraction("34/4", improper = FALSE)
parse_fraction("4 2/4")
parse_fraction("4 2/4", TRUE, FALSE)
parse_fraction("4 2/4", FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.