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

View file

@ -522,36 +522,32 @@ schulte + 3
schulte
#+end_src
**** TODO R [3/5]
**** TODO R [4/5]
- [X] functional results working with comint
- [X] script results
- [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
To redirect output to a file, you can use the =sink()= command.
#+srcname: task_R_B
#+begin_src R :results replace value vector
#+begin_src R :results value vector silent
a <- 9
b <- 10
b - a
a + b
#+end_src
#+resname: task_R_B
| 19 |
#+srcname: task-R-use-other-output
#+begin_src R :var twoentyseven=task_R_B() :results replace value
83
twoentyseven
twoentyseven + 9
#+end_src
#+resname: task-R-use-other-output
| "[1]" | 1 |
| "[1]" | 19 |
: 28
**** 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]])
* 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
for example