org-babel-R is now able to assign variables

This commit is contained in:
Eric Schulte 2009-06-09 15:28:59 -07:00
parent d3f1d07066
commit 39d1674f30
4 changed files with 30 additions and 9 deletions

View File

@ -47,8 +47,9 @@ called by `org-babel-execute-src-block'."
(message "executing R source code block...") (message "executing R source code block...")
(save-window-excursion (save-window-excursion
(let ((vars (org-babel-ref-variables params)) (let ((vars (org-babel-ref-variables params))
(results-params (split-string (cdr (assoc :results params)))) (results-params (split-string (or (cdr (assoc :results params)) "")))
results) results)
;; (message (format "%S" results-params))
(org-babel-R-initiate-R-buffer) (org-babel-R-initiate-R-buffer)
(mapc (lambda (pair) (org-babel-R-assign-elisp (car pair) (cdr pair))) vars) (mapc (lambda (pair) (org-babel-R-assign-elisp (car pair) (cdr pair))) vars)
(cond (cond

View File

@ -132,7 +132,8 @@ return nil."
(mapcar #'org-babel-read row))) (mapcar #'org-babel-read row)))
(org-table-to-lisp))) (org-table-to-lisp)))
('source-block ('source-block
(setq result (org-babel-execute-src-block t nil args)) (setq result (org-babel-execute-src-block
t nil (org-combine-plists args '((:results . "last")))))
(if (symbolp result) (format "%S" result) result)))))) (if (symbolp result) (format "%S" result) result))))))
(defun org-babel-ref-at-ref-p () (defun org-babel-ref-at-ref-p ()

View File

@ -119,7 +119,7 @@ the header arguments specified at the source code block."
(let* ((info (or info (org-babel-get-src-block-info))) (let* ((info (or info (org-babel-get-src-block-info)))
(lang (first info)) (lang (first info))
(body (second info)) (body (second info))
(params (org-combine-plists (third info) params)) (params (org-combine-plists params (third info)))
(cmd (intern (concat "org-babel-execute:" lang))) (cmd (intern (concat "org-babel-execute:" lang)))
result) result)
;; (message (format "params=%S" params)) ;; debugging statement ;; (message (format "params=%S" params)) ;; debugging statement

View File

@ -465,7 +465,7 @@ for the execution of source-code blocks.
with the results (this implies the *script* =:results= with the results (this implies the *script* =:results=
argument as well) argument as well)
*** TODO rework evaluation lang-by-lang [0/4] *** TODO rework evaluation lang-by-lang [1/4]
This should include... This should include...
- functional results working with the comint buffer - functional results working with the comint buffer
@ -478,16 +478,16 @@ This should include...
- sessions in comint buffers - sessions in comint buffers
**** TODO R **** DONE R [3/3]
- [X] functional results working with comint - [X] functional results working with comint
- [X] script results - [X] script results
- [ ] implement echo - [X] ensure callable by other source block
To redirect output to a file, you can use the =sink()= command. To redirect output to a file, you can use the =sink()= command.
#+srcname: task-R-with-inf-process-buffer #+srcname: task_R_B
#+begin_src R :results replace script scalar #+begin_src R :results replace script
a <- 8 a <- 8
b <- 9 b <- 9
c <- 10 c <- 10
@ -501,7 +501,26 @@ a + b + c
: [1] 21 : [1] 21
: [1] 27 : [1] 27
**** TODO Ruby #+srcname: task-R-use-other-output
#+begin_src R :var twoentyseven=task_R_B() :results replace script
83
twoentyseven
#+end_src
#+resname: task-R-use-other-output
: [1] 83
: [1] 27
#+srcname: name
#+begin_src emacs-lisp
(setq debug-on-error t)
#+end_src
**** TODO Ruby [0/3]
- [ ] functional results working with comint
- [ ] script results
- [ ] ensure callable by other source block
#+srcname: ruby-use-last-output #+srcname: ruby-use-last-output
#+begin_src ruby #+begin_src ruby