as_result: Results with rounding

View source: R/result.R

as_resultR Documentation

Results with rounding

Description

Rounds x according to digits, FUN and sets a tolerance for the result. If the tolerance not given it is the maximum of 2*10^(-digits).

Usage

as_result(x, digits, tol = NA, FUN = round2)

tol(x)

rounded(x)

val(x)

digits(x)

Arguments

x

numeric: value to round

digits

integer or character: Digits that should be used for rounding or "integer" for digits=0, "%" for digits=2, or "probability" for digits=4. Abbreviations for the names can be used

tol

numeric: tolerance for result

FUN

function: rounding function (default: round2)

Value

a list with original and rounded value, digits used and tolerance

Examples

x <- as_result(1/3, "prob")
tol(x)
rounded(x)
tol(x)
digits(x)

sigbertklinke/exams2moodle documentation built on July 6, 2023, 3:26 p.m.