Description Usage Arguments Examples
View source: R/compare-reply-answer.R
The comparison is done via a numerical grid.
| 1 2 3 4 5 6 7 8 9 | compare_reply_answer(
  reply,
  answer,
  compare_grid = NULL,
  replace_comma = TRUE,
  ans_tol = 0.01,
  insert_products = TRUE,
  allowed_functions = getGroupMembers("Math")
)
 | 
| reply | user-provided reply as string/character matrix (will be evaluated safely) | 
| answer | the true answer provided as an  | 
| compare_grid | grid to perform comparisons on; must have columns | 
| replace_comma | Replace ',' with '.' before parsing | 
| ans_tol | tolerance for comparisons | 
| insert_products | Make implicit products explicit | 
| allowed_functions | functions (sequence of characters) that should not have products, e.g.  | 
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | compare_reply_answer(reply = "2yx^2", 
                     answer = expression("2*y*x^2"), 
                     compare_grid = expand.grid(x = seq(-10, 10, len = 10), 
                                                y = seq(-10, 10, len = 10)))
compare_reply_answer(reply = "2.1yx^2", 
                     answer = expression("2*y*x^2"), 
                     compare_grid = expand.grid(x = seq(-10, 10, len = 10), 
                                                y = seq(-10, 10, len = 10)))
compare_reply_answer(reply = "2yx^2+0.01", 
                     answer = expression("2*y*x^2"), 
                     compare_grid = expand.grid(x = seq(-10, 10, len = 10), 
                                                y = seq(-10, 10, len = 10)), 
                     ans_tol = 1)
                     
rep <- matrix(c("(1+1)*x", "3*x"), nrow = 1, ncol = 2)
ans <- list(list(expression(2*x)), list(expression(3*x)))
compare_reply_answer(reply = rep,
                     answer = ans,
                     compare_grid = expand.grid(x = seq(-10, 10, len = 10)),
                     ans_tol = 1)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.