Function: org-babel-R-evaluate-session
org-babel-R-evaluate-session is a byte-compiled function defined in
ob-R.el.gz.
Signature
(org-babel-R-evaluate-session SESSION BODY RESULT-TYPE RESULT-PARAMS COLUMN-NAMES-P ROW-NAMES-P)
Documentation
Evaluate BODY in SESSION.
If RESULT-TYPE equals output then return standard output as a
string. If RESULT-TYPE equals value then return the value of the
last statement in BODY, as elisp.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ob-R.el.gz
(defun org-babel-R-evaluate-session
(session body result-type result-params column-names-p row-names-p)
"Evaluate BODY in SESSION.
If RESULT-TYPE equals `output' then return standard output as a
string. If RESULT-TYPE equals `value' then return the value of the
last statement in BODY, as elisp."
(cl-case result-type
(value
(with-temp-buffer
(insert (org-babel-chomp body))
(let ((ess-local-process-name
(process-name (get-buffer-process session)))
(ess-eval-visibly-p nil))
(ess-eval-buffer nil)))
(let ((tmp-file (org-babel-temp-file "R-")))
(org-babel-comint-eval-invisibly-and-wait-for-file
session tmp-file
(format org-babel-R-write-object-command
(if row-names-p "TRUE" "FALSE")
(if column-names-p
(if row-names-p "NA" "TRUE")
"FALSE")
".Last.value" (org-babel-process-file-name tmp-file 'noquote)))
(org-babel-R-process-value-result
(org-babel-result-cond result-params
(with-temp-buffer
(insert-file-contents tmp-file)
(org-babel-chomp (buffer-string) "\n"))
(org-babel-import-elisp-from-file tmp-file '(16)))
column-names-p)))
(output
(mapconcat
'org-babel-chomp
(butlast
(delq nil
(mapcar
(lambda (line) (when (> (length line) 0) line))
(mapcar
(lambda (line) ;; cleanup extra prompts left in output
(if (string-match
"^\\([>+.]\\([ ][>.+]\\)*[ ]\\)"
(car (split-string line "\n")))
(substring line (match-end 1))
line))
(with-current-buffer session
(let ((comint-prompt-regexp (concat "^" comint-prompt-regexp)))
(org-babel-comint-with-output (session org-babel-R-eoe-output)
(insert (mapconcat 'org-babel-chomp
(list body org-babel-R-eoe-indicator)
"\n"))
(inferior-ess-send-input)))))))) "\n"))))