Round a decimal to the precise decimal value of a specified fractional denominator. Common use cases include addressing floating point imprecision and enforcing that data values fall into a certain set.
E.g., if a decimal represents hours and values should be logged to the nearest
round_to_fraction(x, 60) would enforce that distribution and 0.57
would be rounded to 0.566667, the equivalent of 34/60. 0.56 would also be rounded
denominator = 1 to round to whole numbers.
digits argument allows for rounding of the subsequent result.
A numeric vector
The denominator of the fraction for rounding (a scalar or vector positive integer).
Integer indicating the number of decimal places to be used
after rounding to the fraction. This is passed to
x is rounded to the fraction
and then kept at full precision. If
number of digits is automatically selected as
ceiling(log10(denominator)) + 1.
the input x rounded to a decimal value that has an integer numerator relative
denominator (possibly subsequently rounded to a number of decimal
1 2 3 4 5
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.