fractional {fractional}R Documentation

Representation of a numeric vector in vulgar fractional form

Description

The object is flagged so that if it is coerced to character, or printed, the numerical quantities are represented by a rational approximation. In other respects the numerical object behaves as normally.

Usage

fractional(x, eps = 1e-06, maxConv = 20, sync = FALSE)

## S3 method for class 'fractional'
as.character(x, eps = attr(x, "eps"), maxConv = attr(x,
  "maxConv"), ...)

## S3 method for class 'charFrac'
print(x, ...)

## S3 method for class 'fractional'
print(x, ...)

Arguments

x

A numeric object

eps

An absolute error tolerance

maxConv

An upper limit on the number of convergents to use in the continued fractions.

sync

A logical value. Should the numerical value be changed to match the rational approximation, as closely as possible with floating point, (TRUE)? Or, should it be left and used in its original state (FALSE)?

...

Currently ignored.

Value

A numeric object of class "fractional".

Methods (by generic)

See Also

fractions for a similar functionality.

Examples

(M <- solve(cbind(1, contr.helmert(5))))
(Mf <- fractional(M))     ## print method right justifies
(Mc <- as.character(Mf))  ## print method left justifies
(Mn <- numerical(Mc))
set.seed(123)
u <- matrix(runif(10), 2, 5)
(uf <- fractional(u))
(us <- fractional(u, sync = TRUE))  ## may look different!
unfractional(uf) - unfractional(us)  ## rational approximation errors

[Package fractional version 0.1.3 Index]