Ratio object


Stores the numerator, denominator, and value of a ratio as a single object.


rat(ratio, numerator, denominator, check = TRUE)



Three objects belonging to the same class.


Logical. Whether to check that the objects are compatible.


The class "rat" is a simple mechanism for keeping track of the numerator and denominator when calculating a ratio. Its main purpose is simply to signal that the object is a ratio.

The function rat creates an object of class "rat" given the numerator, the denominator and the ratio. No calculation is performed; the three objects are simply stored together.

The arguments ratio, numerator, denominator can be objects of any kind. They should belong to the same class. It is assumed that the relationship

ratio = numerator/denominator

holds in some version of arithmetic. However, no calculation is performed.

By default the algorithm checks whether the three arguments ratio, numerator, denominator are compatible objects, according to compatible.

The result is equivalent to ratio except for the addition of extra information.


An object equivalent to the object ratio except that it also belongs to the class "rat" and has additional attributes numerator and denominator.



and \rolf

See Also

compatible, pool

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.

comments powered by Disqus