TODO allow tangle to be called on a single source block
[org-mode.git] / library-of-babel.org
blob6518c81c55fa75803e482f016b2132e445d25ad0
1 #+title:    The Library of Babel
2 #+SEQ_TODO: TODO PROPOSED | DONE DEFERRED REJECTED
3 #+OPTIONS:  H:3 num:nil toc:2 \n:nil @:t ::t |:t ^:t -:t f:t *:t TeX:t LaTeX:t skip:nil d:(HIDE) tags:not-in-toc
4 #+STARTUP:  odd hideblocks
6 #+begin_html 
7   <div id="subtitle">
8     <p>
9       off-the-shelf functions for data analysis and plotting using <a href="org-babel-worg.html">org-babel</a><br/>
10       <a href="http://downlode.org/Etext/library_of_babel.html">Full text of the Borges short story</a>
11     </p>
12   </div>
13   <div id="logo">
14     <p>
15       <img src="images/library-of-babel.png"  alt="images/tower-of-babel.png" />
16       <div id="attr">
17         from <a href="http://www.poetryfoundation.org/harriet/2008/01/random-poetry-02/">poetryfoundation.org</a>
18       </div>
19     </p>  
20   </div>
21 #+end_html
23 * Introduction
24   The Library of Babel is an extensible collection of ready-made and
25   easily-shortcut-callable source-code blocks for handling common
26   tasks.  Org-babel comes pre-populated with the source-code blocks
27   located in this file. It is possible to add source-code blocks from
28   any org-mode file to the library by calling =(org-babel-lob-ingest
29   "path/to/file.org")=.
31 * Plotting code
33 ** R
34   Plot column 2 (y axis) against column 1 (x axis). Columns 3 and beyond, if present, are ignored.
36 #+srcname: R-plot(data=R-plot-example-data)
37 #+begin_src R :session *R*
38 plot(data)
39 #+end_src
41 #+tblname: R-plot-example-data
42 | 1 |  2 |
43 | 2 |  4 |
44 | 3 |  9 |
45 | 4 | 16 |
46 | 5 | 25 |
48 #+lob: R-plot(data=R-plot-example-data)
50 #+resname: R-plot(data=R-plot-example-data)
51 : nil
53 ** Gnuplot
55 * Table/Matrix manipulation
57 Elegant lisp code for transposing a matrix.
59 #+tblname: transpose-example
60 | 1 | 2 | 3 |
61 | 4 | 5 | 6 |
63 #+srcname: transpose
64 #+begin_src emacs-lisp :var table=transpose-example
65   (apply #'mapcar* #'list table)
66 #+end_src
68 #+resname:
69 | 1 | 4 |
70 | 2 | 5 |
71 | 3 | 6 |
73 * Misc
74 #+srcname: python-identity(a=1)
75 #+begin_src python
77 #+end_src
79 #+srcname: python-add(a=1, b=2)
80 #+begin_src python
81 a + b
82 #+end_src