[Top][All Lists]

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

Re: [Orgmode] Re: [babel] R - variable names in summary

From: Dan Davison
Subject: Re: [Orgmode] Re: [babel] R - variable names in summary
Date: Wed, 09 Dec 2009 17:28:16 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

> 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].



[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
x <- rnorm(100)
y <- x + rnorm(100)
xtable(summary(lm(y ~ x)))

% latex table generated in R 2.9.2 by xtable 1.5-5 package
% Wed Dec  9 17:17:53 2009
 & Estimate & Std. Error & t value & Pr($>$$|$t$|$) \\ 
(Intercept) & -0.0743 & 0.0969 & -0.77 & 0.4454 \\ 
  x & 1.0707 & 0.0923 & 11.60 & 0.0000 \\ 

> HTH,
> /au

reply via email to

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