refcard-org-babel icon indicating copy to clipboard operation
refcard-org-babel copied to clipboard

Org Babel reference card

#+TITLE: Org Babel reference card #+AUTHOR: Fabrice Niessen #+EMAIL: (concat "fniessen" at-sign "pirilampo.org") #+DESCRIPTION: Org Babel reference card #+KEYWORDS: emacs, org-mode, org-babel, eric shulte, dan davison, literate programming, reproducible research, sweave #+LANGUAGE: en #+OPTIONS: H:4 num:nil toc:2

#+SETUPFILE: https://fniessen.github.io/org-html-themes/setup/theme-readtheorg.setup

#+PROPERTY: header-args :eval never

#+begin_html

#+end_html

#+begin_html :license-gpl-blue.svg

btn_donate_LG.gif #+end_html
  • Introduction

Welcome to Org Babel reference card. It contains the reference documentation that describes how to perform code execution within Org mode documents using Org Babel 8.

In a nutshell, Org Babel is like Sweave (for [[id:1663ff41-af51-4b07-abc8-6bfed9395b2b][reproducible research]]) but it takes a large number of possible languages (C, Java, Python, Ruby, R, ...) and Org mode can produce HTML as well as PDF.

#+begin_warning Prolonged use may cause addiction! #+end_warning

See http://faculty.washington.edu/kenrice/sisg-adv/SweaveIntro.pdf for intro

about Sweave.

* Example

http://www.johndcook.com/blog/2012/12/20/basics-of-sweave-and-pweave/

Here is a sample Org file:

Invisible code that sets the value of the variable ~a~.

<<<echo=FALSE>>=

a <- 3.14

@

Visible code that sets ~b~ and squares it.

<<bear, echo=TRUE>>=

b <- 3.15

b*b

@

Calling R inline: $\sqrt{2} = Sexpr{sqrt(2)}$

Recalling the variable $a$ set above: $a = Sexpr{a}$.

Here's a figure:

<<fig=TRUE, echo=FALSE>>=

x <- seq(0, 6*pi, length=200)

plot(x, sin(x))

@

  • Documentation

See http://org-babel.readthedocs.org/ for full documentation.