#+TITLE: example-1-Rnw.org #+AUTHOR: Charles Berry #+EMAIL: ccberry@ucsd.edu #+DATE: 2014-01-11 Sat #+DESCRIPTION: #+KEYWORDS: #+LANGUAGE: en #+OPTIONS: H:3 num:t toc:nil \n:nil @:t ::t |:t ^:t -:t f:t *:t <:t #+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc #+INFOJS_OPT: view:nil toc:nil ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js #+EXPORT_SELECT_TAGS: export #+EXPORT_EXCLUDE_TAGS: noexport #+LINK_UP: #+LINK_HOME: #+XSLT: * What is Up The next section is the "example-1.Rnw' file from the R distribution, but modified to *.org format. The usual way to export a subtree is to move point into the subtree and issue C-c C-e C-s l r However, running this command: #+BEGIN_SRC emacs-lisp (save-excursion (let ((org-export-latex-default-packages-alist nil)) (progn (forward-line 5) (search-forward "Sweave Example 1") (forward-line 1) (org-export-to-file 'latex-noweb "example-1-fromOrg.Rnw" nil t )))) #+END_SRC #+RESULTS: : example-1-fromOrg.Rnw should translate it back to Sweave. * Sweave Example 1 :PROPERTIES: :EXPORT_TITLE: Sweave Example 1 :EXPORT_AUTHOR: Friedrich Leisch :CUSTOM_ID: ex1AsOrg :END: #+COMMENT: adapted to *.org format by Charles Berry #+LATEX_HEADER: \usepackage{hyperref} #+LaTeX_CLASS: article #+LaTeX_CLASS_OPTIONS: [a4paper] In this example we embed parts of the examples from the =kruskal.test= help page into a \LaTeX{} document: #+BEGIN_SRC R data(airquality, package="datasets") library("stats") kruskal.test(Ozone ~ Month, data = airquality) #+END_SRC #+RESULTS: : example-1-fromOrg.Rnw which shows that the location parameter of the Ozone distribution varies significantly from month to month. Finally we include a boxplot of the data: #+LATEX: \begin{center} #+BEGIN_SRC R :ravel fig=TRUE,echo=FALSE library("graphics") boxplot(Ozone ~ Month, data = airquality) #+END_SRC #+LATEX: \end{center}