num_result: num_result

View source: R/archive/num_result.R

num_resultR Documentation

num_result

Description

num_result creates a list with the elements

Usage

num_result(x, digits = NULL, tolerance = NULL, tolmult = 2, ...)

int_result(x, ...)

Arguments

x

numeric: rounded data

digits

numeric: number of digits to rounding (default: NULL)

tolerance

numeric: tolerance for rounded data (default: NULL)

tolmult

numeric: multiplier for tolerance

...

further parameters to exams::fmt()

Details

  • x the original values

  • fx the rounded values with exams::fmt() as character

  • tolerance the tolerance

  • digits the digits used for rounding

Note that x may contain more than one numeric value to determine the rounding and tolerance. Make sure that you use for numeric exercises ...$x[1].

If digits are not given and length(x)>1 then ceiling(-log10(min(diff(sort(x)), na.rm=TRUE))) is used. If digits are not given and length(x)==1 then 3+ceiling(-log10(abs(x))) is used. If no tolerance is given then tolmult*10^(1-digits) is used.

int_result can be used if the result is an integer number and calls num_result(x, 0, 0.1, 1, ...) with a tolerance of 0.1.

Value

a list

Examples

# height for german man (in meter)
x <- rnorm(10, mean=1.8, sd =0.25)
num_result(c(mean(x), x), digits=2)
int_result(mean(x))
#
str(num_result(pi, 3))
str(num_result(pi, 6))
str(num_result(pi, 6, tolmult=5))
str(num_result(pi, 6, tolmult=5, tolerance=1e-6))

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