An object of this class provides the context in which Jupyter notebook cells are run -- i.e. the expression within are evaluated. Usually there is only one of such objects needed.

Public fields

cell_no

The number of the cell currently executed

cells

A 'dictionary' traitlet with the code of the cells so far encountered

cell_results

A 'dictionary' traitlet with the output of the code cells so far executed

Methods


Method new()

Initialize the object

Usage

Evaluator$new(kernel)

Arguments

kernel

The kernel to which this evaluator belongs


Method startup()

Prepare the object for evaluating expressions

Usage

Evaluator$startup(...)

Arguments

...

Any kind of arguments, ignored.


Method shutdown()

Shut the session down

Usage

Evaluator$shutdown()


Method eval_cell()

Evaluate R code

Usage

Evaluator$eval_cell(code, allow_stdin, silent, store_history, ...)

Arguments

code

A string with R code

allow_stdin

Logical value, whether reading from stdin is allowed.

silent

Logical value, whether output should be created.

store_history

Logical value, whether code history should be recorded.

...

Other arguments, currently ignored


Method get_payload()

Get the payload associated with the result returned from running a Jupyter cell

Usage

Evaluator$get_payload(clear = FALSE)

Arguments

clear

A logical value, whether the payload list should be cleared after returning it.


Method get_status()

Get the execution status ("ok", "error", or "aborted")

Usage

Evaluator$get_status(reset = FALSE)

Arguments

reset

A logical value, whether the status should be reset to "ok" after returning it.


Method set_status()

Set the execution status

Usage

Evaluator$set_status(status)

Arguments

status

A character string, the status to be set ("ok", "error", or "aborted")


Method is_aborted()

Check whether the evaluation of expression is aborted - if TRUE, the execution of the notebook is aborted instead of running to the end (if the user has requested to run all cells of the notebook).

Usage

Evaluator$is_aborted(reset = FALSE)

Arguments

reset

A logical value, whether the status should be reset to FALSE after returning it.


Method quit()

Quit the R session in the kernel. Roughly equivalent to quit, but tells the kernel manager of the jupyter server to shut down the kernel.

Usage

Evaluator$quit(...)

Arguments

...

Any kind of argument, ignored.


Method stream()

Stream text to the frontend.

Usage

Evaluator$stream(text, stream = c("stdout", "stderr"))

Arguments

text

Text to be sent to the frontend

stream

A string to select the stream -- either "stout" or "stderr"


Method clear_output()

Clear the current output cell in the frontend.

Usage

Evaluator$clear_output(wait = FALSE)

Arguments

wait

Logical value, whether to wait until output is cleared.


Method code_is_complete()

Check whether code is syntactically complete.

Usage

Evaluator$code_is_complete(code)

Arguments

code

A character string with code to be checked.


Method get_completions()

Provide completion for code given at point.

Usage

Evaluator$get_completions(code, cursor_pos)

Arguments

code

A character string with code to be checked for completions.

cursor_pos

An integer, the current position of the cursor.


Method cell.options()

Set options locally for the current jupyter notebook cell

Usage

Evaluator$cell.options(...)

Arguments

...

Options, see options.


Method cell.par()

Set graphics parameters locally for the current jupyter notebook cell

Usage

Evaluator$cell.par(...)

Arguments

...

Graphics parameters, see options.


Method print()

A variant of the 'print' function that allows to run hooks before and after after printing. Sends the events "before_print" and "print", see EventManager

Usage

Evaluator$print(x, ...)

Arguments

x

The object to be printed

...

Any additional arguments, see print


Method cat()

A variant of the 'cat' function that allows to run hooks before and after after creating output. Sends the events "before_print" and "print", see EventManager

Usage

Evaluator$cat(
  ...,
  file = "",
  sep = " ",
  fill = FALSE,
  labels = NULL,
  append = FALSE
)

Arguments

...

Any strings to be output, see cat

file

A file name, see cat

sep

A separtor string, see cat

fill

A logical value, see cat

labels

See cat

append

A logical value, see cat


Method str()

A variant of the 'str' function that allows to run hooks before and after after creating output.

Usage

Evaluator$str(object, ...)

Arguments

object

Any object

...

Any additional arguments, see str


Method httpd()

A variant of 'tools:::httpd' that adapts the paths used in HTML-pages if the help system is proxied. Also allows to implement handlers for specific URL patterns via the event mechanism (see EventManager)

Usage

Evaluator$httpd(path, query, ...)

Arguments

path

The relative url, e.g. "/doc/html/something/index.html"

query

The query string (that appeared after '?' in the http request)

...

Any further arguments, passed on to specific handlers


Method get_url()

Get the URL served by the current R kernel

Usage

Evaluator$get_url()


Method get_port()

Get the ip port served by the current R kernel

Usage

Evaluator$get_port()


Method set_port()

Set the ip port served by the current R kernel

Usage

Evaluator$set_port(port)

Arguments

port

The port number, an integer


Method start_httpd()

Start the help server of the R kernel

Usage

Evaluator$start_httpd(port = NULL)

Arguments

port

The port number, an integer; or NULL


Method str2iframe()

Create an HTML iframe tag that refers to some (usually HTML) code

Usage

Evaluator$str2iframe(
  code,
  width = "100%",
  height = 400L,
  class = "rkernel-iframe",
  style = "border-style:none",
  ...
)

Arguments

code

The code to be shown in the iframe

width

The intended width of the iframe, a string or a number

height

The intended height of the iframe, a string or a number

class

The DOM class attribute the iframe, a string

style

The CSS style attribte of the iframe, a string

...

Other arguments, ignored.


Method readline()

Ask the kernel object to send an input request to the frontend

Usage

Evaluator$readline(prompt = "")

Arguments

prompt

A character string


Method restart_graphics()

Restart/recreate the graphics device if for whatever reason it was closed needs to be reinitialized

Usage

Evaluator$restart_graphics()


Method get_help_url()

Get URL of the help system

Usage

Evaluator$get_help_url()


Method get_help_port()

Get port of the help system

Usage

Evaluator$get_help_port()


Method clone()

The objects of this class are cloneable with this method.

Usage

Evaluator$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.