mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-30 00:57:48 +00:00
fixed R bug (now properly ingests all elisp values into R)
This commit is contained in:
parent
a79b75eb78
commit
7cb0ecd476
|
@ -52,25 +52,24 @@ called by `litorgy-execute-src-block'."
|
|||
|
||||
(defun litorgy-R-quote-tsv-field (s)
|
||||
"Quote field S for export to R."
|
||||
(concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"") "\""))
|
||||
(if (stringp s)
|
||||
(concat "\"" (mapconcat 'identity (split-string s "\"") "\"\"") "\"")
|
||||
(format "%S" s)))
|
||||
|
||||
(defun litorgy-R-assign-elisp (name value)
|
||||
"Read the elisp VALUE into a variable named NAME in the current
|
||||
R process in `litorgy-R-buffer'."
|
||||
(unless litorgy-R-buffer
|
||||
(error "No active R buffer"))
|
||||
(unless litorgy-R-buffer (error "No active R buffer"))
|
||||
(litorgy-R-input-command
|
||||
(if (listp value)
|
||||
(let ((transition-file (make-temp-file "litorgy-R-import"))
|
||||
(value (mapcar (lambda (row)
|
||||
(mapcar (lambda (cell)
|
||||
(if (stringp cell)
|
||||
cell
|
||||
(format "%S" cell))) row)) value)))
|
||||
(let ((transition-file (make-temp-file "litorgy-R-import")))
|
||||
;; ensure VALUE has an orgtbl structure (depth of at least 2)
|
||||
(unless (listp (car value)) (setq value (list value)))
|
||||
(with-temp-file transition-file
|
||||
(insert (orgtbl-to-tsv value '(:fmt litorgy-R-quote-tsv-field)))
|
||||
(insert "\n"))
|
||||
(litorgy-R-input-command
|
||||
(format "%s <- read.table(\"%s\", sep=\"\\t\", as.is=TRUE)" name transition-file)))))
|
||||
(format "%s <- read.table(\"%s\", sep=\"\\t\", as.is=TRUE)" name transition-file))
|
||||
(format "%s <- %s" name (litorgy-R-quote-tsv-field value)))))
|
||||
|
||||
(defun litorgy-R-to-elisp (func-name)
|
||||
"Return the result of calling the function named FUNC-NAME in
|
||||
|
|
72
rorg.org
72
rorg.org
|
@ -423,7 +423,7 @@ example in the [[* emacs lisp source reference][emacs lisp source reference]].
|
|||
|
||||
|
||||
|
||||
* Bugs [7/10]
|
||||
* Bugs [8/10]
|
||||
|
||||
** TODO ruby new variable creation
|
||||
Ruby doesn't seem able to handle the creation of new variables
|
||||
|
@ -439,7 +439,33 @@ total/table.size
|
|||
: -:4:in `main': undefined local variable or method `total' for main:Object (NameError)
|
||||
: from -:7
|
||||
|
||||
** TODO R code execution seems to choke on certain inputs
|
||||
** TODO cursor movement when evaluating source blocks
|
||||
E.g. the pie chart example. Despite the save-window-excursion in
|
||||
litorgy-execute:R. (I never learned how to do this properly: org-R
|
||||
jumps all over the place...)
|
||||
|
||||
** DONE R code execution seems to choke on certain inputs
|
||||
Currently the R code seems to work on vertical (but not landscape)
|
||||
tables
|
||||
|
||||
#+srcname: little-fake
|
||||
#+begin_src emacs-lisp
|
||||
"schulte"
|
||||
#+end_src
|
||||
|
||||
#+begin_src R :var num=little-fake
|
||||
num
|
||||
#+end_src
|
||||
|
||||
#+resname:
|
||||
: schulte
|
||||
: 11
|
||||
: 11
|
||||
: 11
|
||||
: schulte
|
||||
: 9
|
||||
: 9
|
||||
: 11
|
||||
|
||||
#+srcname: set-debug-on-error
|
||||
#+begin_src emacs-lisp :results silent
|
||||
|
@ -452,14 +478,22 @@ total/table.size
|
|||
#+end_src
|
||||
|
||||
#+srcname: bug-R-number-evaluation
|
||||
#+begin_src R :var table=bug-numerical-table :results silent
|
||||
mean(table)
|
||||
#+begin_src R :var table=bug-numerical-table :results replace
|
||||
mean(mean(table))
|
||||
#+end_src
|
||||
|
||||
** TODO cursor movement when evaluating source blocks
|
||||
E.g. the pie chart example. Despite the save-window-excursion in
|
||||
litorgy-execute:R. (I never learned how to do this properly: org-R
|
||||
jumps all over the place...)
|
||||
#+resname:
|
||||
: 2
|
||||
|
||||
#+tblname: bug-vert-table
|
||||
| 1 |
|
||||
| 2 |
|
||||
| 3 |
|
||||
|
||||
#+srcname: bug-R-vertical-table
|
||||
#+begin_src R :var table=bug-vert-table :results silent
|
||||
mean(table)
|
||||
#+end_src
|
||||
|
||||
** DEFERRED org bug/request: prevent certain org behaviour within code blocks
|
||||
E.g. [[]] gets recognised as a link (when there's text inside the
|
||||
|
@ -606,28 +640,28 @@ litorgy functionality.
|
|||
|
||||
#+TBLNAME: litorgy-tests
|
||||
| functionality | block | arg | expected | results | pass |
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+-------------------------------|
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+------|
|
||||
| basic evaluation | | | | | pass |
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+-------------------------------|
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+------|
|
||||
| emacs lisp | basic-elisp | | 5 | 5 | pass |
|
||||
| shell | basic-shell | | 6 | 6 | pass |
|
||||
| ruby | basic-ruby | | litorgy | litorgy | pass |
|
||||
| python | basic-python | | hello world | hello world | pass |
|
||||
| R | basic-R | | 13 | 13 | pass |
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+-------------------------------|
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+------|
|
||||
| tables | | | | | pass |
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+-------------------------------|
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+------|
|
||||
| emacs lisp | table-elisp | | 3 | 3 | pass |
|
||||
| ruby | table-ruby | | 1-2-3 | 1-2-3 | pass |
|
||||
| python | table-python | | 5 | 5 | pass |
|
||||
| R | table-R | | 3.5 | 3.5 | pass |
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+-------------------------------|
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+------|
|
||||
| source block references | | | | | pass |
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+-------------------------------|
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+------|
|
||||
| all languages | chained-ref-last | | Array | Array | pass |
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+-------------------------------|
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+------|
|
||||
| source block functions | | | | | pass |
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+-------------------------------|
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+------|
|
||||
| emacs lisp | defun-fibb | | fibbd | fibbd | pass |
|
||||
| run over | Fibonacci | 0 | 1 | 1 | pass |
|
||||
| a | Fibonacci | 1 | 1 | 1 | pass |
|
||||
|
@ -635,11 +669,11 @@ litorgy functionality.
|
|||
| of | Fibonacci | 3 | 3 | 3 | pass |
|
||||
| different | Fibonacci | 4 | 5 | 5 | pass |
|
||||
| arguments | Fibonacci | 5 | 8 | 8 | pass |
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+-------------------------------|
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+------|
|
||||
| bug fixing | | | | | pass |
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+-------------------------------|
|
||||
|-------------------------+-------------------------+-----+-------------+-------------+------|
|
||||
| simple ruby arrays | ruby-array-test | | 3 | 3 | pass |
|
||||
| R number evaluation | bug-R-number-evaluation | | 2 | #ERROR | expected "2" but was "#ERROR" |
|
||||
| R number evaluation | bug-R-number-evaluation | | 2 | 2 | pass |
|
||||
#+TBLFM: $5='(if (= (length $3) 1) (progn (message (format "running %S" '(sbe $2 (n $3)))) (sbe $2 (n $3))) (sbe $2))::$6='(if (string= $4 $5) "pass" (format "expected %S but was %S" $4 $5))
|
||||
|
||||
** basic tests
|
||||
|
|
Loading…
Reference in a new issue