mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-30 03:27:54 +00:00
Proposals for some minor reworkings of litorgy-R.el code added to rorg.org and as comments in litorgy-R.el
This commit is contained in:
parent
47615a1ea8
commit
0c68fce725
28
examples.org
28
examples.org
|
@ -11,23 +11,10 @@ labeled directory-pie and press =\C-c\C-c=.
|
||||||
|
|
||||||
#+srcname: directories
|
#+srcname: directories
|
||||||
#+begin_src bash :results replace
|
#+begin_src bash :results replace
|
||||||
du -sc * |grep -v total
|
du -sc * |grep -v total | head -n 1
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
| 4 | "block" |
|
| 4 | "block" |
|
||||||
| 36 | "COPYING" |
|
|
||||||
| 4 | "#dan-notes.org#" |
|
|
||||||
| 4 | "#examples.org#" |
|
|
||||||
| 4 | "examples.org" |
|
|
||||||
| 256 | "existing_tools" |
|
|
||||||
| 4 | "intro.org" |
|
|
||||||
| 144 | "litorgy" |
|
|
||||||
| 4 | "README.markdown" |
|
|
||||||
| 12 | "rorg.html" |
|
|
||||||
| 68 | "#rorg.org#" |
|
|
||||||
| 68 | "rorg.org" |
|
|
||||||
| 8 | "test-export.html" |
|
|
||||||
| 4 | "test-export.org" |
|
|
||||||
|
|
||||||
[Eric] I sometimes get weird results here, where R will import the
|
[Eric] I sometimes get weird results here, where R will import the
|
||||||
labels into the third column instead of the second. I don't entirely
|
labels into the third column instead of the second. I don't entirely
|
||||||
|
@ -38,16 +25,3 @@ trust the R table importing mechanisms so far.
|
||||||
pie(dirs[,1], labels = dirs[,2])
|
pie(dirs[,1], labels = dirs[,2])
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
| 4 | "block" |
|
|
||||||
| 36 | "COPYING" |
|
|
||||||
| 4 | "dan-notes.org" |
|
|
||||||
| 4 | "#examples.org#" |
|
|
||||||
| 4 | "examples.org" |
|
|
||||||
| 256 | "existing_tools" |
|
|
||||||
| 4 | "intro.org" |
|
|
||||||
| 140 | "litorgy" |
|
|
||||||
| 4 | "README.markdown" |
|
|
||||||
| 12 | "rorg.html" |
|
|
||||||
| 68 | "rorg.org" |
|
|
||||||
| 8 | "test-export.html" |
|
|
||||||
| 4 | "test-export.org" |
|
|
||||||
|
|
|
@ -67,9 +67,13 @@ R process in `litorgy-R-buffer'."
|
||||||
cell
|
cell
|
||||||
(format "%S" cell))) row)) value)))
|
(format "%S" cell))) row)) value)))
|
||||||
(with-temp-file transition-file
|
(with-temp-file transition-file
|
||||||
|
;; DED: I think the :sep "\t" is redundant here as
|
||||||
|
;; orgtbl-to-tsv adds it automatically?
|
||||||
(insert (orgtbl-to-tsv value '(:sep "\t" :fmt litorgy-R-quote-tsv-field)))
|
(insert (orgtbl-to-tsv value '(:sep "\t" :fmt litorgy-R-quote-tsv-field)))
|
||||||
(insert "\n"))
|
(insert "\n"))
|
||||||
(litorgy-R-input-command (format "%s <- read.table(\"%s\", as.is=TRUE)" name transition-file)))))
|
(litorgy-R-input-command
|
||||||
|
(format "%s <- read.table(\"%s\", sep=\"\\t\", as.is=TRUE)" name transition-file)))))
|
||||||
|
|
||||||
|
|
||||||
(defun litorgy-R-to-elisp (func-name)
|
(defun litorgy-R-to-elisp (func-name)
|
||||||
"Return the result of calling the function named FUNC-NAME in
|
"Return the result of calling the function named FUNC-NAME in
|
||||||
|
@ -104,6 +108,8 @@ R process in `litorgy-R-buffer'."
|
||||||
|
|
||||||
(defun litorgy-R-initiate-R-buffer ()
|
(defun litorgy-R-initiate-R-buffer ()
|
||||||
"If there is not a current R process then create one."
|
"If there is not a current R process then create one."
|
||||||
|
;; DED: Ideally I think we should use ESS mechanisms for this sort
|
||||||
|
;; of thing. See ess-force-buffer-current.
|
||||||
(unless (and (buffer-live-p litorgy-R-buffer) (get-buffer litorgy-R-buffer))
|
(unless (and (buffer-live-p litorgy-R-buffer) (get-buffer litorgy-R-buffer))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(R)
|
(R)
|
||||||
|
|
21
rorg.org
21
rorg.org
|
@ -4,8 +4,23 @@
|
||||||
#+STARTUP: oddeven
|
#+STARTUP: oddeven
|
||||||
|
|
||||||
* Tasks [8/19]
|
* Tasks [8/19]
|
||||||
|
** PROPOSED use textConnection to pass tsv to R?
|
||||||
|
When passing args from the org buffer to R, the following route is
|
||||||
|
used: arg in buffer -> elisp -> tsv on file -> data frame in R. I
|
||||||
|
think it would be possible to avoid having to write to file by
|
||||||
|
constructing an R expression in litorgy-R-assign-elisp, something
|
||||||
|
like this
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(litorgy-R-input-command
|
||||||
|
(format "%s <- read.table(textConnection(\"%s\"), sep=\"\\t\", as.is=TRUE)"
|
||||||
|
name (orgtbl-to-tsv value '(:sep "\t" :fmt litorgy-R-quote-tsv-field))))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
I haven't tried to implement this yet as it's basically just
|
||||||
|
fiddling with something that works. The only reason for it I can
|
||||||
|
think of would be efficiency and I haven't tested that.
|
||||||
** PROPOSED re-implement R evaluation using ess-command or ess-execute
|
** PROPOSED re-implement R evaluation using ess-command or ess-execute
|
||||||
I can't see anything wrong with the current R evaluation code or
|
I don't have any complaints with the current R evaluation code or
|
||||||
behaviour, but I think it would be good to use the ESS functions
|
behaviour, but I think it would be good to use the ESS functions
|
||||||
from a political point of view. Plus of course it has the normal
|
from a political point of view. Plus of course it has the normal
|
||||||
benefits of an API (insulates us from any underlying changes etc). [DED]
|
benefits of an API (insulates us from any underlying changes etc). [DED]
|
||||||
|
@ -613,11 +628,11 @@ Time.now
|
||||||
|
|
||||||
#+begin_src R :results replace
|
#+begin_src R :results replace
|
||||||
a <- 9
|
a <- 9
|
||||||
b <- 14
|
b <- 16
|
||||||
a + b
|
a + b
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
: 23
|
: 25
|
||||||
|
|
||||||
#+begin_src R
|
#+begin_src R
|
||||||
hist(rgamma(20,3,3))
|
hist(rgamma(20,3,3))
|
||||||
|
|
Loading…
Reference in a new issue