emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [babel] org mode tables and tangling


From: Andreas Leha
Subject: [O] [babel] org mode tables and tangling
Date: Thu, 12 Jan 2012 19:42:23 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Hi all,

What is the suggested way to use org mode tables in connection with tangling?

Example:  If I tangle this org mode file

/====<org-file>=====================================\
| * org-tables and reproducibility                  |
|   #+name: params                                  |
|   | number | param |                              |
|   |--------+-------|                              |
|   |      0 |     1 |                              |
|   |      1 |     1 |                              |
|                                                   |
|   #+begin_src R :var params=params :tangle test.R |
|     apply(params, 1, print)                       |
|   #+end_src                                       |
\====</org-file>====================================/

the tangled file looks like

/====<test.R>===============================================================\
| params <- read.table("/tmp/babel-19196cip/R-import-19196ILE",             |
|                        header=TRUE, row.names=NULL, sep="\t", as.is=TRUE) |
| attach(params)                                                            |
| apply(params, 1, print)                                                   |
\====</test.R>==============================================================/

which depends on a temporary file.  I could distribute that along with the
tangled file, of course.

But I'd like a distributable, ideally self-contained version, that my
co-workers can work with.

Something like this, maybe:

/====<sample.R>=======================================================\
| # generated with R dput()...                                        |
| babel_tmp_1238h098 <- structure(list(means = 0:1, sds = c(1L, 1L)), |
|                                 .Names = c("means", "sds"),         |
|                                 class = "data.frame",               |
|                                 row.names = c(NA, -2L))             |
| params <- dget(textConnection("babel_tmp_1238h098", "r"))           |
\====</sample.R>======================================================/

Is such a mode of tangling already available for R?

Best,
Andreas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]