emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Org-babel & R exporting multiple tables
@ 2013-05-22 21:26 Joe Bogner
  2013-05-22 22:57 ` Joe Bogner
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Bogner @ 2013-05-22 21:26 UTC (permalink / raw)
  To: emacs-orgmode

I have a list of data frames that I would like to output. The number
of frames may vary

Is there a way to export multiple tables formatted? These are the
three options I came up with. None of them work very well:

Option #3 works the best, but it will append each time it's run in the
doc, so I can't have the contents in the doc without having it
duplicated.

Option #2 would be good if I could just instruct it to render the table as HTML

There was a post about 2 years ago that I attempted implement by
adding (require 'ob-org) to my .emacs for #2 but it didn't seem to
work (http://article.gmane.org/gmane.emacs.orgmode/29286/match=results+org+babel+ascii).



* Option 1

Will combine the frames

#+begin_src R :session *R* :colnames yes
frames <- list()
frames[[1]] <- data.frame(col=c("a","b"))
frames[[2]] <- data.frame(col2=c("a","b"))
frames
#+end_src

#+RESULTS:
| col | col2 |
|-----+------|
| a   | a    |
| b   | b    |



* Option 2

It won't format on export

#+begin_src R :session *R* :results output org :exports both
frames <- list()
frames[[1]] <- data.frame(col=c("a","b"))
frames[[2]] <- data.frame(col2=c("a","b"))
for(i in 1:2) {
    print(ascii(frames[[i]]), type="org")
cat("\n")
}
#+end_src

#+RESULTS:
#+BEGIN_SRC org
 |   | col |
 |---+-----|
 | 1 | a   |
 | 2 | b   |

|   | col2 |
|---+------|
| 1 | a    |
| 2 | b    |
#+END_SRC


* Option 3

It will format on export but won't replace if it's run in the document

#+begin_src R :session *R* :results output raw :exports both
frames <- list()
frames[[1]] <- data.frame(col=c("a","b"))
frames[[2]] <- data.frame(col2=c("a","b"))
for(i in 1:2) {
    print(ascii(frames[[i]]), type="org")
cat("\n")
}
#+end_src

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Org-babel & R exporting multiple tables
  2013-05-22 21:26 Org-babel & R exporting multiple tables Joe Bogner
@ 2013-05-22 22:57 ` Joe Bogner
  2013-05-23  1:37   ` Eric Schulte
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Bogner @ 2013-05-22 22:57 UTC (permalink / raw)
  To: emacs-orgmode

Figured it out. Option #2 works with ob-org as long as the defaults
are set to output the results

(setq org-babel-default-header-args:org '((:results . "raw") (:exports
. "results")))

By default it looks like it's silent.



On Wed, May 22, 2013 at 5:26 PM, Joe Bogner <joebogner@gmail.com> wrote:
> I have a list of data frames that I would like to output. The number
> of frames may vary
>
> Is there a way to export multiple tables formatted? These are the
> three options I came up with. None of them work very well:
>
> Option #3 works the best, but it will append each time it's run in the
> doc, so I can't have the contents in the doc without having it
> duplicated.
>
> Option #2 would be good if I could just instruct it to render the table as HTML
>
> There was a post about 2 years ago that I attempted implement by
> adding (require 'ob-org) to my .emacs for #2 but it didn't seem to
> work (http://article.gmane.org/gmane.emacs.orgmode/29286/match=results+org+babel+ascii).
>
>
>
> * Option 1
>
> Will combine the frames
>
> #+begin_src R :session *R* :colnames yes
> frames <- list()
> frames[[1]] <- data.frame(col=c("a","b"))
> frames[[2]] <- data.frame(col2=c("a","b"))
> frames
> #+end_src
>
> #+RESULTS:
> | col | col2 |
> |-----+------|
> | a   | a    |
> | b   | b    |
>
>
>
> * Option 2
>
> It won't format on export
>
> #+begin_src R :session *R* :results output org :exports both
> frames <- list()
> frames[[1]] <- data.frame(col=c("a","b"))
> frames[[2]] <- data.frame(col2=c("a","b"))
> for(i in 1:2) {
>     print(ascii(frames[[i]]), type="org")
> cat("\n")
> }
> #+end_src
>
> #+RESULTS:
> #+BEGIN_SRC org
>  |   | col |
>  |---+-----|
>  | 1 | a   |
>  | 2 | b   |
>
> |   | col2 |
> |---+------|
> | 1 | a    |
> | 2 | b    |
> #+END_SRC
>
>
> * Option 3
>
> It will format on export but won't replace if it's run in the document
>
> #+begin_src R :session *R* :results output raw :exports both
> frames <- list()
> frames[[1]] <- data.frame(col=c("a","b"))
> frames[[2]] <- data.frame(col2=c("a","b"))
> for(i in 1:2) {
>     print(ascii(frames[[i]]), type="org")
> cat("\n")
> }
> #+end_src

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Org-babel & R exporting multiple tables
  2013-05-22 22:57 ` Joe Bogner
@ 2013-05-23  1:37   ` Eric Schulte
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Schulte @ 2013-05-23  1:37 UTC (permalink / raw)
  To: Joe Bogner; +Cc: emacs-orgmode

Joe Bogner <joebogner@gmail.com> writes:

> Figured it out. Option #2 works with ob-org as long as the defaults
> are set to output the results
>
> (setq org-babel-default-header-args:org '((:results . "raw") (:exports
> . "results")))
>
> By default it looks like it's silent.
>

Another option may be to try option 3, but replace

  :results output raw

with

  :results output drawer

Best,

>
>
>
> On Wed, May 22, 2013 at 5:26 PM, Joe Bogner <joebogner@gmail.com> wrote:
>> I have a list of data frames that I would like to output. The number
>> of frames may vary
>>
>> Is there a way to export multiple tables formatted? These are the
>> three options I came up with. None of them work very well:
>>
>> Option #3 works the best, but it will append each time it's run in the
>> doc, so I can't have the contents in the doc without having it
>> duplicated.
>>
>> Option #2 would be good if I could just instruct it to render the table as HTML
>>
>> There was a post about 2 years ago that I attempted implement by
>> adding (require 'ob-org) to my .emacs for #2 but it didn't seem to
>> work (http://article.gmane.org/gmane.emacs.orgmode/29286/match=results+org+babel+ascii).
>>
>>
>>
>> * Option 1
>>
>> Will combine the frames
>>
>> #+begin_src R :session *R* :colnames yes
>> frames <- list()
>> frames[[1]] <- data.frame(col=c("a","b"))
>> frames[[2]] <- data.frame(col2=c("a","b"))
>> frames
>> #+end_src
>>
>> #+RESULTS:
>> | col | col2 |
>> |-----+------|
>> | a   | a    |
>> | b   | b    |
>>
>>
>>
>> * Option 2
>>
>> It won't format on export
>>
>> #+begin_src R :session *R* :results output org :exports both
>> frames <- list()
>> frames[[1]] <- data.frame(col=c("a","b"))
>> frames[[2]] <- data.frame(col2=c("a","b"))
>> for(i in 1:2) {
>>     print(ascii(frames[[i]]), type="org")
>> cat("\n")
>> }
>> #+end_src
>>
>> #+RESULTS:
>> #+BEGIN_SRC org
>>  |   | col |
>>  |---+-----|
>>  | 1 | a   |
>>  | 2 | b   |
>>
>> |   | col2 |
>> |---+------|
>> | 1 | a    |
>> | 2 | b    |
>> #+END_SRC
>>
>>
>> * Option 3
>>
>> It will format on export but won't replace if it's run in the document
>>
>> #+begin_src R :session *R* :results output raw :exports both
>> frames <- list()
>> frames[[1]] <- data.frame(col=c("a","b"))
>> frames[[2]] <- data.frame(col2=c("a","b"))
>> for(i in 1:2) {
>>     print(ascii(frames[[i]]), type="org")
>> cat("\n")
>> }
>> #+end_src
>

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-23  1:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-22 21:26 Org-babel & R exporting multiple tables Joe Bogner
2013-05-22 22:57 ` Joe Bogner
2013-05-23  1:37   ` Eric Schulte

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