R evaluation is pretty much up to snuff

This commit is contained in:
Eric Schulte 2009-06-12 08:29:21 -07:00
parent 86e4597a7a
commit 82e7c86ea3
2 changed files with 21 additions and 16 deletions

View File

@ -126,11 +126,8 @@ last statement in BODY."
(accept-process-output (get-buffer-process buffer))) (accept-process-output (get-buffer-process buffer)))
;; remove filter ;; remove filter
(remove-hook 'comint-output-filter-functions 'my-filt)) (remove-hook 'comint-output-filter-functions 'my-filt))
;; ;;; debugging ;; (message (format "raw-results=%S" string-buffer)) ;; debugging
;; ;; echo raw results
;; (message (format "raw-results=%S" string-buffer))
;; ;; split results ;; ;; split results
(message (format "split-results=%S" (split-string string-buffer comint-prompt-regexp)))
;; split results with `comint-prompt-regexp' ;; split results with `comint-prompt-regexp'
(setq results (let ((broke nil)) (setq results (let ((broke nil))
(delete nil (mapcar (lambda (el) (delete nil (mapcar (lambda (el)
@ -144,8 +141,8 @@ last statement in BODY."
el)))) el))))
(mapcar #'org-babel-trim (split-string string-buffer comint-prompt-regexp)))))) (mapcar #'org-babel-trim (split-string string-buffer comint-prompt-regexp))))))
(case result-type (case result-type
(output (mapconcat #'identity results "\n")) (output (org-babel-trim (mapconcat #'identity results "\n")))
(value (with-temp-buffer (insert-file-contents tmp-file) (buffer-string))) (value (org-babel-trim (with-temp-buffer (insert-file-contents tmp-file) (buffer-string))))
(t (reverse results)))))) (t (reverse results))))))
(provide 'org-babel-R) (provide 'org-babel-R)

View File

@ -522,36 +522,32 @@ schulte + 3
schulte schulte
#+end_src #+end_src
**** TODO R [3/5] **** TODO R [4/5]
- [X] functional results working with comint - [X] functional results working with comint
- [X] script results - [X] script results
- [X] ensure scalar/vector results args are taken into consideration - [X] ensure scalar/vector results args are taken into consideration
- [ ] ensure callable by other source block - [X] ensure callable by other source block
- [ ] rename buffer after session - [ ] rename buffer after session
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_B #+srcname: task_R_B
#+begin_src R :results replace value vector #+begin_src R :results value vector silent
a <- 9 a <- 9
b <- 10 b <- 10
b - a b - a
a + b a + b
#+end_src #+end_src
#+resname: task_R_B
| 19 |
#+srcname: task-R-use-other-output #+srcname: task-R-use-other-output
#+begin_src R :var twoentyseven=task_R_B() :results replace value #+begin_src R :var twoentyseven=task_R_B() :results replace value
83 83
twoentyseven twoentyseven + 9
#+end_src #+end_src
#+resname: task-R-use-other-output #+resname: task-R-use-other-output
| "[1]" | 1 | : 28
| "[1]" | 19 |
**** TODO Python **** TODO Python
@ -1526,7 +1522,19 @@ This could probably be added to [[file:lisp/org-babel-script.el][org-babel-scrip
(see [[* file result types][file result types]]) (see [[* file result types][file result types]])
* Bugs [11/14] * Bugs [11/15]
** TODO when reading results from =#+resname= line
Errors when trying to read from resname lines.
#+resname: bug-in-resname
: 8
#+srcname: bug-in-resname-reader
#+begin_src emacs-lisp :var buggy=bug-in-resname() :results silent
buggy
#+end_src
** TODO non-orgtbl formatted lists ** TODO non-orgtbl formatted lists
for example for example