R | R Documentation |
Evaluates an expression and records its direct and indirect effects:
the resulting value as well as the information whether any errors,
warnings, or messages are generated and if anything is printed on
stdout
or stderr
.
R(expr, ..., envir = parent.frame())
expr |
expression to be evaluated |
... |
further arguments to be passed to |
envir |
environment where |
Note that messages, warnings, and errors are typically written to
stderr
, but these are considered separately here.
In other words, when testing expectations with E
,
e.g., the reference stderr
should not include the anticipated
diagnostic messages.
There may be other side effects, such as changing the state of the random number generator, modifying options or environment variables, modifying the calling or global environment (e.g., creating new global variables), attaching objects onto the search part (e.g., loading package namespaces), or plotting, but these will not be captured, at least, not by the current version of the realtest package.
A list of class realtest_descriptor
,
see P
, which this function calls.
The additional named component expr
gives the
expression that generated the value
.
Moreover, args
gives a named list of objects
that appeared in expr
(not including functions called).
If an effect of particular kind does not occur,
it is not included in the resulting list.
stdout
, stderr
, and error
are at most single strings.
When an error occurs, value
is NULL
.
The official online manual of realtest at https://realtest.gagolewski.com/
Related functions:
E
, P
y <- 1:10; R(sum(y^2))
R(cat("a bit talkative, innit?"))
R(sqrt(c(-1, 0, 1, 2, 4)))
R(log("aaaargh"))
R({
cat("STDOUT"); cat("STDERR", file=stderr()); message("MESSAGE");
warning("WARNING"); warning("WARNING AGAIN"); cat("MORE STDOUT");
message("ANOTHER MESSAGE"); stop("ERROR"); y; "NO RETURN VALUE"
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.