From: "Cook, Malcolm" <MEC@stowers.org>
To: 'John Hendy' <jw.hendy@gmail.com>
Cc: 'Rob Stewart' <robstewart57@gmail.com>,
"'emacs-orgmode@gnu.org'" <emacs-orgmode@gnu.org>,
'Andreas Leha' <andreas.leha@med.uni-goettingen.de>
Subject: Re: import R data frame into org-mode table
Date: Mon, 29 Jul 2013 20:17:27 +0000 [thread overview]
Message-ID: <D4772401B9D976478C0895769BE3E792BBC0D2@MBSRV02.sgc.loc> (raw)
In-Reply-To: <CA+M2ft-wi7hoe9QcrYymSLt9nznnr-bEtRnKgsM_dLyOY3OLcg@mail.gmail.com>
>-----Original Message-----
>From: John Hendy [mailto:jw.hendy@gmail.com]
>Sent: Monday, July 29, 2013 11:03 AM
>To: Cook, Malcolm
>Cc: Rob Stewart; Andreas Leha; emacs-orgmode@gnu.org
>Subject: Re: [O] import R data frame into org-mode table
>
>On Mon, Jul 29, 2013 at 10:35 AM, Cook, Malcolm <MEC@stowers.org> wrote:
>>>Hi Andreas,
>> >
>> >On 17 July 2013 23:09, Andreas Leha <andreas.leha@med.uni-goettingen.de> wrote:
>> >
>> >> Definitely there is:
>> >>
>> >> --8<---------------cut here---------------start------------->8---
>> >> #+begin_src R :results table :colnames yes
>> >> read.csv('test.csv')
>> >> #+end_src
>> >>
>> >> #+results:
>> >> | X | Variant | Xaxis | N | mean | sd | se |
>> >> |---+---------+-------+---+--------+------+------|
>> >> | 1 | line1 | 10 | 5 | 111.11 | 9.33 | 3.11 |
>> >> | 1 | line1 | 20 | 5 | 112.11 | 9.13 | 3.14 |
>> >> | 1 | line1 | 30 | 5 | 113.11 | 9.43 | 3.1 |
>> >> | 1 | line2 | 10 | 5 | 101.11 | 8.33 | 2.11 |
>> >> | 1 | line2 | 20 | 5 | 100.11 | 8.13 | 2.12 |
>> >> | 1 | line2 | 30 | 5 | 108.11 | 8.03 | 2.1 |
>> >>
>> >> --8<---------------cut here---------------end--------------->8---
>> >
>> >Great. I've gone ahead and done this. There are two additional requirements:
>> >1) My table needs a caption. Will #+CAPTION: just above the
>> >#+BEGIN_SRC just work?
>>
>> Yes
>>
>>> Even better, a label, allowing me to also cross
>> >reference it.
>> >2) My table is too long for 1 page. It spans multiple pages
>> >vertically. According to this StackOverflow answer
>> >http://stackoverflow.com/a/2896850/1526266 , I should instead use
>> >longtable, not tabular. Is there a way to coerce your above snippet to
>> >use longtable, instead of tabular which is the default.
>> >
>>
>> Looks like your answer is here: http://orgmode.org/manual/Tables-in-LaTeX-export.html
>
>Sort of. Depends on the Org-mode version, and someone will have to
>chime in on the updated status of various parts of the manual. For 8+,
>I believe the syntax is different:
>
>#+attr_latex: :environment longtable
>
>Also, there have been many threads in the past about how to add
>#+attr_latex lines to results output (mostly graphics/files)
>successfully. If you simply take the above and add =#+attr_latex:
>stuff= above the =#+results= line, babel won't recognize it and will
>just create a new results block. If those on this email are already
>well aware of this... my apologies for being redundant, but it causes
>enough confusion that I figured I'd leave another bread crumb trail :)
>Here's an example of a time that came up on the list:
>- http://lists.gnu.org/archive/html/emacs-orgmode/2012-07/msg00237.html
>
>You need to use any attributes (that includes #+begin/end_center, and
>any #+attr_backend lines) *in combination with* a named source block.
>So the full solution should look something like this:
>
>#+name: export-table
>#+begin_src R :results table :colnames yes
>read.csv('test.csv')
>#+end_src
>
>#+RESULTS: export-table
>#+attr_latex: :environment longtable
>| | |
[Cook, Malcolm]
Indeed, thanks, and, my worked out example follows using emacs 2.18.9 and org-mode version 8.0.6
#+LATEX: \listoftables
#+LaTeX_HEADER: \usepackage{longtable}
#+name: longtabletest
#+CAPTION: test of longtable caption
#+begin_src R :results value :colnames yes
data.frame(num=1:260,alpha=rep(LETTERS,10))
#+end_src
#+RESULTS:
#+attr_latex: :environment longtable
| num | alpha |
|-----+-------|
| 1 | A |
| 2 | B |
...
~Malcolm
>
>I see above that =:results output org= was used. There was some
>discussion about this for use with the new exporter as I wasn't
>getting great results:
>- https://lists.gnu.org/archive/html/emacs-orgmode/2013-03/msg01582.html
>- http://www.mail-archive.com/emacs-orgmode@gnu.org/msg69748.html
>
>If it's working for you, don't worry about it. If not, you may find
>some help in those threads. I've taken to using the ascii package for
>output org-mode tables from R.
>- http://orgmode.org/worg/org-contrib/babel/examples/ascii.html
>
>Works great for me.
>
>
>Good luck!
>John
>
>
>>
>> >Thanks!
>> >
>> >--
>> >Rob
>>
>>
next prev parent reply other threads:[~2013-07-29 20:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-16 15:19 import R data frame into org-mode table Rob Stewart
2013-07-17 22:09 ` Andreas Leha
2013-07-29 14:42 ` Rob Stewart
2013-07-29 15:35 ` Cook, Malcolm
2013-07-29 16:03 ` John Hendy
2013-07-29 17:11 ` Nick Dokos
2013-07-29 20:17 ` Cook, Malcolm [this message]
2013-07-29 21:40 ` Nick Dokos
2013-07-30 17:59 ` Cook, Malcolm
2013-07-17 22:48 ` Thomas S. Dye
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=D4772401B9D976478C0895769BE3E792BBC0D2@MBSRV02.sgc.loc \
--to=mec@stowers.org \
--cc=andreas.leha@med.uni-goettingen.de \
--cc=emacs-orgmode@gnu.org \
--cc=jw.hendy@gmail.com \
--cc=robstewart57@gmail.com \
/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).