forked from mirrors/org-mode
R results now obey the scalar/vector :results header arguments
This commit is contained in:
parent
e0dcbce75e
commit
86e4597a7a
|
@ -45,7 +45,6 @@ called by `org-babel-execute-src-block'."
|
|||
(t 'value)))
|
||||
(session (org-babel-R-initiate-session ;; (cdr (assoc :session params))
|
||||
(get-buffer "*R*")))
|
||||
;; (session (get-buffer "*R*"))
|
||||
results)
|
||||
;; assign variables
|
||||
(mapc (lambda (pair) (org-babel-R-assign-elisp session (car pair) (cdr pair))) vars)
|
||||
|
@ -53,11 +52,17 @@ called by `org-babel-execute-src-block'."
|
|||
;; (message (format "result-type=%S" result-type))
|
||||
;; (message (format "body=%S" body))
|
||||
;; (message (format "session=%S" session))
|
||||
;; (message (format "result-params=%S" result-params))
|
||||
;; evaluate body and convert the results to ruby
|
||||
(setq results (org-babel-R-evaluate session body result-type))
|
||||
(let ((tmp-file (make-temp-file "org-babel-R")))
|
||||
(with-temp-file tmp-file (insert results))
|
||||
(org-babel-import-elisp-from-file tmp-file)))))
|
||||
(setq results (if (member "scalar" result-params)
|
||||
results
|
||||
(let ((tmp-file (make-temp-file "org-babel-R")))
|
||||
(with-temp-file tmp-file (insert results))
|
||||
(org-babel-import-elisp-from-file tmp-file))))
|
||||
(if (and (member "vector" result-params) (not (listp results)))
|
||||
(list (list results))
|
||||
results))))
|
||||
|
||||
(defun org-babel-R-quote-tsv-field (s)
|
||||
"Quote field S for export to R."
|
||||
|
|
|
@ -478,10 +478,11 @@ This should include...
|
|||
|
||||
- sessions in comint buffers
|
||||
|
||||
**** DONE Ruby [4/4]
|
||||
**** DONE Ruby [4/5]
|
||||
|
||||
- [X] functional results working with comint
|
||||
- [X] script results
|
||||
- [ ] ensure scalar/vector results args are taken into consideration
|
||||
- [X] ensure callable by other source block
|
||||
- [X] rename buffer after session
|
||||
|
||||
|
@ -521,17 +522,18 @@ schulte + 3
|
|||
schulte
|
||||
#+end_src
|
||||
|
||||
**** TODO R [2/4]
|
||||
**** TODO R [3/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
|
||||
- [ ] 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
|
||||
#+begin_src R :results replace value vector
|
||||
a <- 9
|
||||
b <- 10
|
||||
b - a
|
||||
|
@ -539,7 +541,7 @@ a + b
|
|||
#+end_src
|
||||
|
||||
#+resname: task_R_B
|
||||
: 19
|
||||
| 19 |
|
||||
|
||||
#+srcname: task-R-use-other-output
|
||||
#+begin_src R :var twoentyseven=task_R_B() :results replace value
|
||||
|
|
Loading…
Reference in a new issue