| solution | R Documentation |
Creates a solution object and prints a meta information block:
solution the default is sol_num
sol_num for a numerical solution
sol_int for an integer solution
sol_mc for a multiple choice solution
sol_ans for the answer list of a multiple choice solution
sol_tf for the solution list (True or False) of a multiple choice solution
sol_info for creating a Meta-Information block
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, ...)
x |
numeric solution or false MC solutions |
... |
further parameters |
tol |
numeric: a tolerance for a numeric solution (default: |
digits |
integer: number of digits for rounding (default: |
y |
true MC solutions |
sample |
integer: sampling numbers for false and/or true solutions (default: |
shuffle |
logical or function: shuffling or ordering of solutions (default |
none |
character: if you do not wish to choose any of the false and true solutions offered (default: |
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.
a solution object
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.