babel: allow assigning of variables when preparing R session

This is already in place for other languages, but seems to have been
forgotten for R.
This commit is contained in:
Dan Davison 2010-04-08 15:26:08 -04:00
parent 6f3026edf1
commit 38d6bf3f6c
1 changed files with 9 additions and 3 deletions

View File

@ -59,8 +59,14 @@ called by `org-babel-execute-src-block'."
(defun org-babel-prep-session:R (session params)
"Prepare SESSION according to the header arguments specified in PARAMS."
(let* ((session (org-babel-R-initiate-session session params))
(vars (org-babel-ref-variables params)))
(mapc (lambda (pair) (org-babel-R-assign-elisp session (car pair) (cdr pair))) vars)
(vars (org-babel-ref-variables params))
(var-lines
(mapcar
(lambda (pair) (org-babel-R-assign-elisp (car pair) (cdr pair))) vars)))
(org-babel-comint-in-buffer session
(mapc (lambda (var)
(move-end-of-line 1) (insert var) (comint-send-input nil t)
(org-babel-comint-wait-for-output session)) var-lines))
session))
(defun org-babel-load-session:R (session body params)
@ -81,7 +87,7 @@ called by `org-babel-execute-src-block'."
(format "%S" s)))
(defun org-babel-R-assign-elisp (name value)
"Read the elisp VALUE into a variable named NAME."
"Construct R code assigning the elisp VALUE to a variable named NAME."
(if (listp value)
(let ((transition-file (make-temp-file "org-babel-R-import")))
;; ensure VALUE has an orgtbl structure (depth of at least 2)