as_result | R Documentation |
Rounds x
according to digits
and the rounding function FUN
, and sets
a tolerance for the result. If tol
is not provided, it defaults to 2*10^(-digits)
.
as_result(x, digits, tol = NA, FUN = round2)
tol(x)
rounded(x)
val(x)
digits(x)
as_res(x, digits, tol = NA, FUN = round2)
tolerance(x)
x |
numeric: value to round |
digits |
integer or character: Number of digits to use for rounding, see Details. |
tol |
numeric: tolerance for the result (defaults to |
FUN |
function: rounding function (default: internal |
Results with Rounding
Creates a structured result with a numeric value rounded according to specified digits, an optional tolerance, and a rounding function.
By default, rounding is performed using an internal function round2()
, which is similar
to exams::round2()
, but users should not call it directly. You can also supply a
custom rounding function via the FUN
argument.
If digits
is a character, the following abbreviations are recognized:
"integer"
digits = 0
"%"
digits = 2
"probability"
digits = 4
Partial matching of these names is allowed.
A list of class result
containing:
x |
Original value |
r |
Rounded value |
digits |
Digits used for rounding |
tol |
Tolerance for the result |
x <- as_result(1/3, "probability")
tol(x)
rounded(x)
digits(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.