fracture: Convert decimals to a character vector of fractions

Description Usage Arguments Value See Also Examples

View source: R/fracture.R

Description

Convert decimals to a character vector of fractions

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
fracture(
  x,
  base_10 = FALSE,
  common_denom = FALSE,
  mixed = FALSE,
  max_denom = 1e+07
)

as.fracture(x)

is.fracture(x)

Arguments

x

A vector of decimals or, for as.fracture(), a matrix created by frac_mat()

base_10

If TRUE, all denominators will be a power of 10.

common_denom

If TRUE, all fractions will have the same denominator.

If the least common denominator is greater than max_denom, max_denom is used.

mixed

If TRUE, integer components will be displayed separately from fractional components for x values greater than 1.

If FALSE, improper fractions will be used for x values greater than 1.

max_denom

All denominators will be less than or equal to max_denom.

If base_10 is TRUE, the maximum denominator will be the largest power of 10 less than max_denom.

A max_denom greater than the inverse square root of machine double epsilon will produce a warning because floating point rounding errors can occur when denominators grow too large.

Value

A character vector.

See Also

frac_mat() to return a matrix of numerators and denominators.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
x <- (6:1) / (1:6)

fracture(x)
fracture(x, common_denom = TRUE)

fracture(x, base_10 = TRUE)
fracture(x, base_10 = TRUE, max_denom = 100)
fracture(x, base_10 = TRUE, common_denom = TRUE)
fracture(x, base_10 = TRUE, common_denom = TRUE, max_denom = 100)

fracture(x, mixed = TRUE)
fracture(x, mixed = TRUE, common_denom = TRUE)
fracture(x, mixed = TRUE, base_10 = TRUE)
fracture(x, mixed = TRUE, base_10 = TRUE, max_denom = 100)
fracture(x, mixed = TRUE, base_10 = TRUE, common_denom = TRUE)
fracture(x, mixed = TRUE, base_10 = TRUE, common_denom = TRUE, max_denom = 100)

fracture documentation built on Sept. 8, 2020, 5:06 p.m.