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
.
An object equivalent to the object ratio
except that it also belongs to the class "rat"
and has additional attributes numerator
and denominator
.
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
$$
\mbox{ratio} = \frac{\mbox{numerator}}{\mbox{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.