check.assign: Checks an assignment to a variable

View source: R/tests_for_ps.r

check.assignR Documentation

Checks an assignment to a variable

Description

By default a solution is considered correct if the assignment yields the same value than the sample solution, or has the same rhs (e.g. a call runif(1,0,1)), even if the value differs.

Usage

check.assign(
  call,
  check.arg.by.value = TRUE,
  allow.extra.arg = FALSE,
  ignore.arg = NULL,
  success.message = NULL,
  failure.message = NULL,
 
    no.command.failure.message = "You have not yet included correctly, all required R commands in your code...",
  ok.if.same.val = TRUE,
  call.object = NULL,
  s3.method = NULL,
  ps = get.ps(),
  stud.env = ps$stud.env,
  part = ps$part,
  stud.expr.li = ps$stud.expr.li,
  verbose = FALSE,
  only.check.assign.exists = FALSE,
  noeval = isTRUE(ps$noeval),
  other.sols = NULL,
  check.cols = NULL,
  sort.cols = NULL,
  ...
)

Arguments

call

the correct assignment that shall be checked (not a quoted call)

allow.extra.arg

if TRUE (not default) the student is allowed to supply additional arguments to the call that were not in the solution. Useful, e.g. if the student shall plot something and is allowed to customize her plot with additional arguments.

ignore.arg

a vector of argument names that will be ignored when checking correctness

ok.if.same.val

if TRUE (default) the call will be considered as correct, if it yields the same resulting value as the solution, even if its arguments differ.

call.object

alternatively to call a quoted call (call object)

only.check.assign.exists

if TRUE (default = FALSE) only check if an assignemnt to the lhs variable exists no matter whether the assignment is correct. May be sensible if there are additional tests specified afterwards that check some characteristics of the assigned variable.

other.sols

a list of quoted assignments, e.g. list(quote(x<-5), quote(x<-10)) of other solutions that are also correct.

check.cols

only relevant if a data frame (or tibble) is computed. An optional character vector of column names. If provided only check whether those columns are correctly computed but ignore other columns. Only works if compare.vals = TRUE (default).

sort.cols

only relevant if a data frame (or tibble) is computed. An optional character vector of column names. If provided sort the sample solution and student's solution by these columns before comparing. This means that also solutions that are originally sorted in a different fashion are accepted. Useful in combination with check.cols.


skranz/RTutor documentation built on Feb. 7, 2024, 12:53 a.m.