From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: Re: [babel] R - variable names in summary Date: Wed, 09 Dec 2009 17:28:16 -0500 Message-ID: <878wdbvl33.fsf@stats.ox.ac.uk> References: <2c75873c0912081550m5da3861fgb3a14f047f8638ae@mail.gmail.com> <87k4wwf6h1.fsf@stats.ox.ac.uk> <2c75873c0912090905y5d673fe3m879e7e79e77f3c89@mail.gmail.com> <87vdggdkob.fsf@stats.ox.ac.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NIV1G-0004QK-7x for emacs-orgmode@gnu.org; Wed, 09 Dec 2009 17:28:26 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NIV1A-0004PF-Pu for emacs-orgmode@gnu.org; Wed, 09 Dec 2009 17:28:25 -0500 Received: from [199.232.76.173] (port=34849 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NIV1A-0004PC-K1 for emacs-orgmode@gnu.org; Wed, 09 Dec 2009 17:28:20 -0500 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:53069) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NIV1A-0006lc-3O for emacs-orgmode@gnu.org; Wed, 09 Dec 2009 17:28:20 -0500 In-Reply-To: (Austin Frank's message of "Wed, 09 Dec 2009 15:49:52 -0500") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Austin Frank Cc: emacs-orgmode@gnu.org > You can also look at the latex() function in the R package Hmisc and the > function xtable() from the R package xtable. For data frames, matrices, > and some common summary functions, these functions will create a latex > table out of your R object. Maybe Dan can suggest how latex code > generated in R could be properly included and typeset in org-babel. Hi Austin, If one does need to resort to generating latex code directly from a language then we have ':results latex', which ensures that the results are wrapped in a begin_latex block. And as you point out, those R functions could have their place even in the org-babel framework, as they can make tabular latex output out of very non-tabular stuff[1] E.g. below[2]. Dan Footnotes: [1] Of course it would be better if they generated org tables; maybe we should start an R package for it (oRg?), one day. [2] This example summarises a linear regression fit. Neither the printed representation nor the value of summary(lm(y ~ x)) is at all tabular, but the xtable function outputs a latex table which can be included in the org buffer and thus in exported latex. #+begin_src R :results output latex library(xtable) x <- rnorm(100) y <- x + rnorm(100) xtable(summary(lm(y ~ x))) #+end_src #+results: #+BEGIN_LaTeX % latex table generated in R 2.9.2 by xtable 1.5-5 package % Wed Dec 9 17:17:53 2009 \begin{table}[ht] \begin{center} \begin{tabular}{rrrrr} \hline & Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\ \hline (Intercept) & -0.0743 & 0.0969 & -0.77 & 0.4454 \\ x & 1.0707 & 0.0923 & 11.60 & 0.0000 \\ \hline \end{tabular} \end{center} \end{table} #+END_LaTeX > > HTH, > /au