From: Dan Davison <davison@stats.ox.ac.uk>
To: Austin Frank <austin.frank@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Re: [babel] R - variable names in summary
Date: Wed, 09 Dec 2009 17:28:16 -0500 [thread overview]
Message-ID: <878wdbvl33.fsf@stats.ox.ac.uk> (raw)
In-Reply-To: <m0aaxrlvnz.fsf@gmail.com> (Austin Frank's message of "Wed, 09 Dec 2009 15:49:52 -0500")
> 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
prev parent reply other threads:[~2009-12-09 22:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-08 23:50 [babel] R - variable names in summary Graham Smith
2009-12-09 4:38 ` Austin Frank
2009-12-09 16:46 ` Graham Smith
2009-12-09 16:38 ` Dan Davison
2009-12-09 17:05 ` Graham Smith
2009-12-09 19:14 ` Dan Davison
2009-12-09 20:33 ` Graham Smith
2009-12-09 20:44 ` Dan Davison
2009-12-09 21:00 ` Graham Smith
2009-12-09 20:51 ` Thomas S. Dye
2009-12-09 21:06 ` Graham Smith
2009-12-09 20:49 ` Austin Frank
2009-12-09 21:12 ` Graham Smith
2009-12-09 22:28 ` Dan Davison [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878wdbvl33.fsf@stats.ox.ac.uk \
--to=davison@stats.ox.ac.uk \
--cc=austin.frank@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).