#+TITLE:How to Use Emacs Org-Babel Mode to Write Literate Programming Document in R Language #+AUTHOR: Feiming Chen #+EMAIL: fullname at yahoo #+BABEL: :session *R* :cache yes :results output graphics :exports both :tangle yes * Introduction We introduce the use of emacs org-babel model in this document. Emacs Org-Babel mode is a literate programming tool (aka. active document), which can embed multiple programming languages, inlcuding R, in one document. Another popular literate programming tool for statisticians is the Sweave document, which can embed only R code. First we clarify the following terminologies: - [[http://www.gnu.org/software/emacs/][Emacs]] :: The extensible, customizable, self-documenting real-time display editor. - [[http://www.gnu.org/software/emacs/][Org-mode]] :: An Emacs Mode for keeping notes, maintaining ToDo lists, doing project planning, and authoring with a fast and effective plain-text system. - [[http://orgmode.org/worg/org-contrib/babel/][Babel]] :: It is Org-mode's ability to execute source code within Org-mode documents. * How to Use ** Installation (August 5, 2011) =Babel= is available after Org-mode version 7.0, while Emacs version 23.2.1 still only has Org-mode version 6.33x. Thus you need to update Org-mode (currenly at version 7.7) from [[http://orgmode.org][Org Home Page]]. You can use Emacs Package Manager to install Org-mode easily following [[http://orgmode.org/worg/org-faq.html#installing-via-elpa][this instruction. ]] ** Keyboard Shortcuts To write a code block in a =.org= file, you can simple type =