| rational | R Documentation |
R has no built in rational number representation; humdrumR defines one.
rational(numerator, denominator = as.integer64(1L))
e1 %R% e2
numerator(x)
denominator(x)
## S4 method for signature 'rational'
numerator(x)
## S4 method for signature 'rational'
denominator(x)
is.rational(x)
## S4 method for signature 'rational'
is.numeric(x)
## S4 method for signature 'rational'
rank(x, na.last = TRUE, ties.method = "average")
## S4 method for signature 'rational,rational'
Compare(e1, e2)
## S4 method for signature 'rational,ANY'
Compare(e1, e2)
## S4 method for signature 'ANY,rational'
Compare(e1, e2)
## S4 method for signature 'rational'
Summary(x)
## S4 method for signature 'rational'
prod(x, ..., na.rm = FALSE)
## S4 method for signature 'rational'
abs(x)
## S4 method for signature 'rational'
sign(x)
## S4 method for signature 'rational'
max(x, ..., na.rm = FALSE)
## S4 method for signature 'rational'
min(x, ..., na.rm = FALSE)
## S4 method for signature 'rational'
mean(x)
## S4 method for signature 'rational'
round(x)
## S4 method for signature 'rational'
floor(x)
## S4 method for signature 'rational'
ceiling(x)
## S4 method for signature 'rational'
trunc(x)
## S4 method for signature 'rational'
expand(x)
## S4 method for signature 'rational'
sum(x, ..., na.rm = FALSE)
## S4 method for signature 'rational'
cumsum(x)
as.rational(x, ...)
## S4 method for signature 'rational'
as.rational(x, ...)
## S4 method for signature 'matrix'
as.rational(x)
## S4 method for signature 'integer'
as.rational(x)
## S4 method for signature 'numeric'
as.rational(x)
## S4 method for signature 'logical'
as.rational(x)
## S4 method for signature 'character'
as.rational(x, sep = "/|%")
## S4 method for signature 'fraction'
as.rational(x, sep = "/|%")
fraction(numerator, denominator, sep = "/")
as.fraction(x, sep = "/")
## S3 method for class 'fraction'
as.double(x)
## S3 method for class 'fraction'
as.integer(x)
Using rational numbers, we can represent numbers like 1/3 without any numeric inaccuracies.
In other words, 1/3 * 3 = 3, never .999999999.
On the other hand, if our rational numbers start to have numerators or demoninators that are too large, we can run into
integer overflow problems.
Since the rational numbers we'll be using in the context of music analysis are relatively simple,
we can safely use such numbers without any numeric inaccuracy.
fraction is a class (and associated constructor) which represents rational numbers as character strings.
Unlike rational, the fraction class is not numeric and thus cannot do arithmetic.
However, fraction can be converted to/from rational.
as.real() as.numeric()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.