From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [babel] org mode tables and tangling Date: Sat, 14 Jan 2012 10:55:11 -0700 Message-ID: <87ipke5fuo.fsf@gmx.com> References: <871ur4yd80.fsf@med.uni-goettingen.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:51742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm7p2-0001xM-5O for emacs-orgmode@gnu.org; Sat, 14 Jan 2012 12:55:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rm7p0-00065g-GZ for emacs-orgmode@gnu.org; Sat, 14 Jan 2012 12:55:20 -0500 Received: from mailout-us.gmx.com ([74.208.5.67]:34448) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Rm7p0-00065b-Ab for emacs-orgmode@gnu.org; Sat, 14 Jan 2012 12:55:18 -0500 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Andreas Leha Cc: emacs-orgmode@gnu.org Andreas Leha writes: > Hi all, > > What is the suggested way to use org mode tables in connection with tangling? > Currently there is no support for including table values literally inline in tangled R code. While some languages (e.g., the lisps) do include table values literally, R is not one of those. You could customize (read rewrite) the `org-babel-R-assign-elisp' function to use literal R tables instead of importing values from an external file. Alternately, if not too many values need to be included into the code, you may want to simply assign individual cells of the table as scalars in your R code. Hope this helps, sorry no pre-built solution exists > > Example: If I tangle this org mode 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 | > \========================================/ > > the tangled file looks like > > /===================================================================\ > | 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) | > \==================================================================/ > > 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: > > /===========================================================\ > | # 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")) | > \==========================================================/ > > Is such a mode of tangling already available for R? > > Best, > Andreas > > -- Eric Schulte http://cs.unm.edu/~eschulte/