numerical {fractional} | R Documentation |
Convert a fractional object to the equivalent numeric object
Description
Convert an object of class "fractional"
or "charFrac"
to a purely
numeric object. This is effectively a method function for the .Primitive
generic function as.numeric
but written as a separate function for purely
technical reasons.
Usage
numerical(vulgar)
## S3 method for class 'fractional'
numerical(vulgar)
## S3 method for class 'charFrac'
numerical(vulgar)
## Default S3 method:
numerical(vulgar)
Arguments
vulgar |
character string form of a class 'fractional' object. |
Value
A numeric
object as represented by its (usually fractional
) display.
Methods (by class)
-
fractional
: Method for"fractional"
objects -
charFrac
: Method for"charFrac"
objects -
default
: Default method fornumerical
generic
Examples
suppressPackageStartupMessages(library(dplyr))
m <- 2*diag(5)
m[abs(row(m) - col(m)) == 1] <- -1
m ## How much roundoff error does inverting entail?
(mi <- solve(m) %>% fractional) ## patterned inverse
mi * max(denominators(mi)) ## clearer pattern
m1 <- solve(mi)
range(m1 - m) ## roundoff still present
m2 <- m1 %>% numerical ## remove roundoff error - hopefully!
identical(m2, m) ## no roundoff
[Package fractional version 0.1.3 Index]