myFrac: Print Fraction for markdown

Description Usage Arguments Value Note Author(s) See Also Examples

Description

Converts fractions for inline rendering.

Usage

1
myFrac(num, denom, format = "markdown")

Arguments

num

Either a vector of values for the numerators, or, if denom is NULL, fractions using "/" as the separator (allows passing fractions directly, as from fractions)

denom

Vector of values for the denominators, or NULL (the default) if num is already formatted fractions.

format

Character vector of length one giving the format of the output. Default of "markdown" uses super script for the numerator, a slash, then subscript for the denominator. Alternatively, "latex" uses \frac and surrounds the fraction with $ to induce LaTeX conversion (via MathJax for html output)

Value

Character vector of the fractions

Note

If passing fractions, the function assumes that there is exactly one "/" in each fraction, and will return "NA" for the denominator if none is present or truncate the fraction if more than one "/" is included.

Author(s)

Mark Peterson

See Also

fractions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
myFrac(3,4)

myFrac(1:3,4:6)

myFrac(1:3,4:6, "latex")

myFrac(letters[1:5], LETTERS[1:5])

myFrac( c("1/2","3/4", "9856/5646") )

myFrac( c("1/2","3/4", "9856/5646"), format = "latex" )

rmdHelpers documentation built on May 1, 2019, 7:33 p.m.