Objects from this class handle the "higher-level" interaction between the frontend and the R session. There can be more such interfaces to a session. For example, for the main REPL and for a REPL created by a call to browser().
Public fields
sessionAn RKernelSession object or `NULL`
promptThe R console prompt or NULL
browse_promptThe prompt created by a call to `browser()`
io_timeoutAn integer number a timeout in microseconds
stdoutAccumulated output via the stdout channel.
stderrAccumulated output via the stderr channel.
stdout_callbackA function to be called with stdout text or NULL
stderr_callbackA function to be called with stderr text or NULL
browser_callbackA function to be called when a browser prompt is encountered or NULL
prompt_callbackA function to be called when a command prompt is encountered or NULL
input_callbackA function to be called when input is required or NULL
echoA logical value, if TRUE code sent to the R process will be echoed
found_promptA logical value, whether a prompt has been found in the output of the R process
found_browse_promptThe latest instance of the browser prompt pattern found in the R process output
erroredA logical value, whether an error occurred in the R session
Methods
Method aggreg_stdout()
A potential "stdout_callback" function that aggregates output sent from the R process via "stdout" channel to the eponymous "stdout" field
Method aggreg_stderr()
A potential "stderr_callback" function that aggregates output sent from the R process via "stderr" channel to the eponymous "stderr" field
Method collect()
Collect the accumulated output from fields "stdout" and "stderr" into a list with two elements named "stdout" and "stderr".
Method new()
Initialize an object
Usage
RSessionAdapter$new(
  session,
  stdout_callback = self$aggreg_stdout,
  stderr_callback = self$aggreg_stderr,
  browser_callback = NULL,
  prompt_callback = NULL,
  input_callback = NULL,
  prompt = "> ",
  echo = FALSE
)Arguments
sessionAn object from class "RKernelSession"
stdout_callbackA callback function for "stdout" output
stderr_callbackA callback function for "stderr" output
browser_callbackA callback function for browser prompts (optional)
prompt_callbackA callback function for command prompts encountered
input_callbackA callback function for input requests (optional)
promptA character string, the expected command prompt
echoA logical value, whether to echo input
Method run_code()
Run code and pass output to callback functions
Usage
RSessionAdapter$run_code(
  code,
  io_timeout = 1,
  stdout_callback = self$stdout_callback,
  stderr_callback = self$stderr_callback,
  browser_callback = self$browser_callback,
  prompt_callback = self$prompt_callback,
  input_callback = self$input_callback,
  until_prompt = TRUE,
  echo = self$echo,
  debug = FALSE
)Arguments
codeA character string or character vector with code lines
io_timeoutAn integer value, the timeout of waiting for output
stdout_callbackA callback function for "stdout" output
stderr_callbackA callback function for "stderr" output
browser_callbackA callback function for browser prompts (optional)
prompt_callbackA callback function for command prompts encountered
input_callbackA callback function for input requests (optional)
until_promptA logical value, whether process and wait output until a command prompt is encountered.
echoA logical value, whether to echo input
Method interrupt()
Send an interrupt signal (SIGINT) to the R process. This should stop what the R process is doing without killing it.
Method process_output()
Process output created by commands sent to the R process
Usage
RSessionAdapter$process_output(
  io_timeout = 1,
  stdout_callback = self$stdout_callback,
  stderr_callback = self$stderr_callback,
  browser_callback = self$browser_callback,
  input_callback = self$input_callback,
  prompt_callback = self$prompt_callback,
  drop_echo = FALSE,
  debug = FALSE
)Arguments
io_timeoutAn integer value, the timeout of waiting for output
stdout_callbackA callback function for "stdout" output
stderr_callbackA callback function for "stderr" output
browser_callbackA callback function for browser prompts (optional)
input_callbackA callback function for input requests (optional)
prompt_callbackA callback function for command prompts encountered
drop_echoA logical value, whether input echo be dropped
until_promptA logical value, whether process and wait output until a command prompt is encountered.
Method getOption()
Get an option value from the R session
Method eval()
Evaluate an expression in the R session and return the result.
Method get()
Get the value of a variable (named object) from the R session and return it.
Method assign()
Assign a value to a variable in the R session
Method handle_readline()
Handle special an input request obtained from the R session via output indicated with a special output string
Arguments
txtOutput string containing a special readline prompt
input_callbackA function to request input from the frontend
stdout_callbackA function to process output obtained from the R session via "stdout" channel
stderr_callbackA function to process output obtained from the R session via "stderr" channel
Method handle_scan()
Handle input request created by the function `scan` the in the R session
Arguments
txtOutput string containing a special readline prompt
input_callbackA function to request input from the frontend
stdout_callbackA function to process output obtained from the R session via "stdout" channel
stderr_callbackA function to process output obtained from the R session via "stderr" channel