solution {exams.forge}R Documentation

Solutions

Description

Creates a solution object and prints a meta information block for the following:

Usage

solution(x, ...)

## Default S3 method:
solution(x, ...)

sol_int(x, tol = NA, digits = NA)

sol_num(x, tol = NA, digits = NA)

sol_mc(x, y, sample = NULL, shuffle = order, none = NULL)

sol_ans(x, ...)

sol_tf(x, ...)

sol_info(x, ...)

sol_mc_ans(x, ...)

sol_meta(x, ...)

sol_mc_tf(x, ...)

Arguments

x

numeric solution or false MC solutions

...

further parameters

tol

numeric: tolerance for a numeric solution (default: NA)

digits

integer: number of digits for rounding (default: NA)

y

true MC solutions

sample

integer: sampling numbers for false and/or true solutions (default: NULL)

shuffle

logical or function: shuffling or ordering of solutions (default order)

none

character: if you do not wish to choose any of the false and/or true solutions offered (default: NULL)

Details

For numerical solutions you can set tol and/or digits. If they are not set, they are automatically selected. If tol is not set and length(x)>1 then the tolerance is chosen as min(diff(sort(x)))/2. Otherwise, as max(0.001, 0.001*abs(x)). I If tol is negative, tolerance is set to 10^tol, otherwise it is used as it is. If digits is not set, ceiling(-log10(tolerance)) is used.

Value

A solution object.

Examples

s <- sol_num(pi)
sol_info(s)
# set same tolerances, e.g. for a probability
sol_num(0.1)
sol_num(0.1, tol=0.001)
sol_num(0.1, tol=-3)
# MC: Which are prime numbers?
prime <- c(2, 3, 5, 7, 11, 13, 17, 19, 23, 29)
nonprime <- setdiff(2:30, prime)
# choose five false and two correct solutions
s <- sol_mc(nonprime, prime, sample=c(5,2), none="There are no prime numbers in the list")  
sol_ans(s)
sol_tf(s)
sol_info(s)

[Package exams.forge version 1.0.10 Index]