| test | R Documentation | 
Evaluate or compare an expression based on a reference expression, or test for errors.
The comparison of expression values is done using base::all.equal().
test(
  key = "test",
  x,
  y = TRUE,
  error = FALSE,
  warning = FALSE,
  runOnly = FALSE,
  text = "",
  onFail = c("fail", "warn", "ignore", "skip"),
  ...
)
key | 
 Identifier for the test condition.  | 
x | 
 The expression to test.  | 
y | 
 The reference value or expression.  | 
error | 
 Whether to expect an error, or the pattern that the error message should match.  | 
warning | 
 Whether to expect a warning, or the pattern that the warning message should match.  | 
runOnly | 
 Whether to skip the comparison to   | 
text | 
 Human-readable description of what this test condition is testing.  | 
onFail | 
 How to handle a failure of the test condition. By default, this is recorded as a test failure.
If   | 
... | 
 Additional arguments passed to   | 
Inspired by the data.table package test mechanism.
The original motivation for this function is the lack of R support for a proper stack trace with line numbers when sourcing files,
which made it practically impossible to identify the offending line in a sourced file.
Whether the test condition has passed successfully. In case of onFail = "skip", NA is returned.
## Not run: 
test('gt', 2 > 1)
test('eq', 1 + 1, 2)
test('lt', 2 < 1, onFail = "warn")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.