Objects of this class are used to capture textual and graphical output, e.g. to display them in Jupyter notebook cells or dedicated widgets.

Public fields

last.value

Value of last evaluated expression.

Methods


Method new()

Initialize the object

Usage

Context$new(envir = list(), attachment = list())

Arguments

envir

An optional environment within which expressions are evaluated

attachment

An optional environment that is attached while an expression is evaluated within the context.


Method do()

Evaluate one or several expressions

Usage

Context$do(..., envir = NULL, enclos = parent.frame())

Arguments

...

A single expression or several expressions included in curly braces.

envir

A list or an environment or NULL

enclos

An enclosing an environment (see eval).


Method eval()

Evaluate a single expression

Usage

Context$eval(expr, envir = NULL, enclos = parent.frame())

Arguments

expr

A single expression.

envir

A list or an environment or NULL

enclos

An enclosing an environment (see eval).


Method evaluate()

Evaluate a single expression

Usage

Context$evaluate(expressions, envir = NULL, enclos = parent.frame())

Arguments

expressions

A list of expressions.

envir

A list or an environment or NULL

enclos

An enclosing an environment (see eval).


Method enter()

A function that is called before a set of expressions is evaluated (e.g. in a notebook cell).

Usage

Context$enter(enclos = parent.frame())

Arguments

enclos

An enclosing environment.


Method exit()

A function that is called after a set of expressions is evaluated (e.g. in a notebook cell).

Usage

Context$exit()


Method on_enter()

Add or remove a handler function to be called by the enter() function, i.e. before a series of expression is evaluated.

Usage

Context$on_enter(handler, remove = FALSE)

Arguments

handler

A handler function

remove

A logical value, whether the handler should be removed or added


Method on_exit()

Add or remove a handler function to be called by the exit() function, i.e. after a series of expression has been evaluated.

Usage

Context$on_exit(handler, remove = FALSE)

Arguments

handler

A handler function

remove

A logical value, whether the handler should be removed or added


Method on_eval()

Add or remove a handler function to be called after every time an expression has been evaluated.

Usage

Context$on_eval(handler, remove = FALSE)

Arguments

handler

A handler function

remove

A logical value, whether the handler should be removed or added


Method on_result()

Add or remove a handler function to the results of each evaluated expression.

Usage

Context$on_result(handler, remove = FALSE)

Arguments

handler

A handler function. This function must take two arguments, the value resulting from the evalualition of the expression and a logical value, which indicates whether the value is visible. See also withVisible.

remove

A logical value, whether the handler should be removed or added


Method on_error()

Add or remove a handler function to be called if an error condition is raised, e.g. by stop().

Usage

Context$on_error(handler = NULL, remove = FALSE)

Arguments

handler

A handler function

remove

A logical value, whether the handler should be removed or added


Method on_warning()

Add or remove a handler function to be called if an warning is raised, e.g. by stop().

Usage

Context$on_warning(handler = NULL, remove = FALSE)

Arguments

handler

A handler function

remove

A logical value, whether the handler should be removed or added


Method on_message()

Add or remove a handler function to be called if a message is shown.

Usage

Context$on_message(handler = NULL, remove = FALSE)

Arguments

handler

A handler function

remove

A logical value, whether the handler should be removed or added


Method on_print()

Add or remove a handler function to be called if an object is output print().

Usage

Context$on_print(handler = NULL, exit = NULL, remove = FALSE)

Arguments

handler

A handler function to called *before* print()

exit

A handler function to called *after* print()

remove

A logical value, whether the handler should be removed or added


Method on_cat()

Add or remove a handler function to be called if text is output using cat().

Usage

Context$on_cat(handler = NULL, exit = NULL, remove = FALSE)

Arguments

handler

A handler function to called *before* cat()

exit

A handler function to called *after* cat()

remove

A logical value, whether the handler should be removed or added


Method on_str()

Add or remove a handler function to be called if the structure of an object is shown using str().

Usage

Context$on_str(handler = NULL, exit = NULL, remove = FALSE)

Arguments

handler

A handler function to called *before* str()

exit

A handler function to called *after* str()

remove

A logical value, whether the handler should be removed or added


Method get_stdout()

Get text output produced by the expressions last evaluated.

Usage

Context$get_stdout()


Method get_stderr()

Get message output produced by the expressions last evaluated.

Usage

Context$get_stderr()


Method clone()

The objects of this class are cloneable with this method.

Usage

Context$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.