2009-06-12 20:26:28 -04:00
|
|
|
#+title: The Library of Babel --- off-the-shelf functions for data analysis and plotting using org-babel
|
|
|
|
#+SEQ_TODO: TODO PROPOSED | DONE DEFERRED REJECTED
|
|
|
|
#+OPTIONS: H:3 num:nil toc:t
|
|
|
|
#+STARTUP: odd hideblocks
|
|
|
|
|
2009-06-13 22:48:44 -04:00
|
|
|
[[http://downlode.org/Etext/library_of_babel.html][Full text of the Borges short story]]
|
|
|
|
|
2009-06-13 18:52:37 -04:00
|
|
|
(setq lob (org-babel-lob-parse-buffer))
|
|
|
|
(setq x (gethash 'plot lob))
|
|
|
|
(hash-table-count lob)
|
|
|
|
(maphash (lambda (key val) (insert key)) lob)
|
|
|
|
|
2009-06-13 22:48:44 -04:00
|
|
|
|
2009-06-12 20:26:28 -04:00
|
|
|
|
2009-06-14 10:54:55 -04:00
|
|
|
* One Liner
|
|
|
|
Here's a different type of syntax that may work.
|
|
|
|
|
|
|
|
This uses one-liners of the form
|
|
|
|
|
|
|
|
: #+lob:source-block-name variables
|
|
|
|
|
|
|
|
This takes advantage of the functionality already present in
|
|
|
|
[[file:lisp/org-babel-ref.el][org-babel-ref]] for resolving references to other source blocks which
|
|
|
|
may contain variable specifications. See the bottom half of
|
|
|
|
[[file:lisp/org-babel-lob.el][org-babel-lob]] for the new implementation. To test it out load
|
|
|
|
org-babel-lob and press =C-cC-c= on the =#+lob:= line further down.
|
|
|
|
|
|
|
|
#+resname: R-plot-default-data
|
|
|
|
| 0 | 0 |
|
|
|
|
|
|
|
|
#+srcname: my-R-plot
|
|
|
|
#+begin_src R :results silent :var data=R-plot-default-data
|
|
|
|
plot(data)
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+tblname: example-R-plot-data
|
|
|
|
| 1 | 2 |
|
|
|
|
| 2 | 4 |
|
|
|
|
| 3 | 9 |
|
|
|
|
| 4 | 16 |
|
|
|
|
| 5 | 25 |
|
|
|
|
|
|
|
|
#+lob:my-R-plot data=example-R-plot-data
|
|
|
|
|
2009-06-12 20:26:28 -04:00
|
|
|
* Plotting code
|
|
|
|
Plot column 2 (y axis) against column 1 (x axis). Columns 3 and beyond, if present, are ignored.
|
2009-06-14 10:54:55 -04:00
|
|
|
|
|
|
|
#+resname: R-plot-default-data
|
|
|
|
| 0 | 0 |
|
|
|
|
|
|
|
|
#+srcname: R-plot
|
|
|
|
#+begin_src R :results silent :var data=R-plot-default-data
|
2009-06-13 22:48:44 -04:00
|
|
|
plot(data)
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+begin_src babel :srcname plot :var data=10
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+srcname: plot
|
|
|
|
#+begin_src R
|
|
|
|
plot(__data__)
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#+srcname: plot
|
|
|
|
#+begin_src R
|
|
|
|
plot(__data__)
|
|
|
|
#+end_src
|
|
|
|
|
|
|
|
#+resname: plot
|
|
|
|
: org_babel_R_eoe
|
|
|
|
: org_babel_R_eoe
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#+begin_src R
|
|
|
|
79
|
2009-06-12 20:26:28 -04:00
|
|
|
#+end_src
|
|
|
|
|
2009-06-13 22:48:44 -04:00
|
|
|
#+resname:
|
|
|
|
: 79
|
|
|
|
: 78
|
|
|
|
: 77
|