emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* export from R to tables, possible correction to ob-doc-R.org
@ 2014-01-14  2:09 regcl
  2014-01-14  2:27 ` Thomas S. Dye
  2014-01-14  2:29 ` John Hendy
  0 siblings, 2 replies; 3+ messages in thread
From: regcl @ 2014-01-14  2:09 UTC (permalink / raw)
  To: emacs-orgmode

I was looking for an example of the export of R data frames into
tables in html, and the example in ...

http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.org

... did not work for me. I am running ...

GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.8.4) of 2013-09-26 on trouble, modified by Debian

Org-mode version 8.2.5c (release_8.2.5c @ /home/regcl/.emacs.d/lisp/org-mode/lisp/)

Here is the problematic code ...

### START SNIP ###### START SNIP ###### START SNIP ###

: #+BEGIN_SRC R :results output org
:  library(ascii)
:  a <- runif(100)
:  c <- "Quantiles of 100 random numbers"
:  b <- ascii(quantile(a),header=T,include.colnames=T,caption=c)
:  print(b,type="org")
:  rm(a,b,c)
: #+END_SRC
: 
: #+RESULTS:
: #+BEGIN_ORG
: #+CAPTION: Quantiles of 100 random numbers
: | 0%   | 25%  | 50%  | 75%  | 100% |
: |------+------+------+------+------|
: | 0.03 | 0.28 | 0.52 | 0.74 | 1.00 |
: #+END_ORG

The output exported to HTML can be quite nice.

#+RESULTS: 
#+BEGIN_ORG
#+CAPTION: Quantiles of 100 random numbers
|   0% |  25% |  50% |  75% | 100% |
|------+------+------+------+------|
| 0.03 | 0.28 | 0.52 | 0.74 | 1.00 |
#+END_ORG

### END SNIP ###### END SNIP ###### END SNIP ###

... As you can see, this code is statically "rigged" to export in such
a way that it looks like it is working with R. When I try to make the
code live by removing the markup as shown below ...

#+BEGIN_SRC R :results output org
  library(ascii)
  a <- runif(100)
  c <- "Quantiles of 100 random numbers"
  b <- ascii(quantile(a),header=T,include.colnames=T,caption=c)
  print(b,type="org")
  rm(a,b,c)
#+END_SRC

The html produced by ...

C-c C-e h h 

... contains the fontified source code, but no table. 

... C-c C-c on the code block produces these results ...

#+RESULTS:
#+BEGIN_SRC org
,#+CAPTION: Quantiles of 100 random numbers
| 0%   | 25%  | 50%  | 75%  | 100% |
|------+------+------+------+------|
| 0.02 | 0.30 | 0.49 | 0.70 | 0.99 |
#+END_SRC

By trial and error, I discovered that if I change the header arguments
as shown below ...

#+BEGIN_SRC R :results output raw :exports results
  library(ascii)
  a <- runif(100)
  c <- "Quantiles of 100 random numbers"
  b <- ascii(quantile(a),header=T,include.colnames=T,caption=c)
  print(b,type="org")
  rm(a,b,c)
#+END_SRC

... this produces a table in HTML that matches the table produced by
the static code.

... C-c C-c on this code block produces these results ...

#+RESULTS:
#+CAPTION: Quantiles of 100 random numbers
| 0%   | 25%  | 50%  | 75%  | 100% |
|------+------+------+------+------|
| 0.03 | 0.25 | 0.57 | 0.79 | 0.99 |

Can someone tell me if this is how it is supposed to work?

If so, how do I go about submiting a patch to ...

http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.org

Thanks,
regcl

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

* Re: export from R to tables, possible correction to ob-doc-R.org
  2014-01-14  2:09 export from R to tables, possible correction to ob-doc-R.org regcl
@ 2014-01-14  2:27 ` Thomas S. Dye
  2014-01-14  2:29 ` John Hendy
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas S. Dye @ 2014-01-14  2:27 UTC (permalink / raw)
  To: regcl; +Cc: emacs-orgmode

Aloha regcl,

regcl <regcl@channing.harvard.edu> writes:

> Can someone tell me if this is how it is supposed to work?

Yes, this is how it should work.

> If so, how do I go about submiting a patch to ...
>
> http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.org

You should be able to edit the document directly. See
http://orgmode.org/worg/worg-git.html#contribute-to-worg for the full
instructions.

Thanks for catching this.

All the best,
Tom

-- 
Thomas S. Dye
http://www.tsdye.com

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

* Re: export from R to tables, possible correction to ob-doc-R.org
  2014-01-14  2:09 export from R to tables, possible correction to ob-doc-R.org regcl
  2014-01-14  2:27 ` Thomas S. Dye
@ 2014-01-14  2:29 ` John Hendy
  1 sibling, 0 replies; 3+ messages in thread
From: John Hendy @ 2014-01-14  2:29 UTC (permalink / raw)
  To: regcl; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 3804 bytes --]

On Mon, Jan 13, 2014 at 8:09 PM, regcl <regcl@channing.harvard.edu> wrote:

> I was looking for an example of the export of R data frames into
> tables in html, and the example in ...
>
> http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.org
>
> ... did not work for me. I am running ...
>
> GNU Emacs 24.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.8.4) of 2013-09-26
> on trouble, modified by Debian
>
> Org-mode version 8.2.5c (release_8.2.5c @
> /home/regcl/.emacs.d/lisp/org-mode/lisp/)
>
> Here is the problematic code ...
>
> ### START SNIP ###### START SNIP ###### START SNIP ###
>
> : #+BEGIN_SRC R :results output org
> :  library(ascii)
> :  a <- runif(100)
> :  c <- "Quantiles of 100 random numbers"
> :  b <- ascii(quantile(a),header=T,include.colnames=T,caption=c)
> :  print(b,type="org")
> :  rm(a,b,c)
> : #+END_SRC
> :
> : #+RESULTS:
> : #+BEGIN_ORG
> : #+CAPTION: Quantiles of 100 random numbers
> : | 0%   | 25%  | 50%  | 75%  | 100% |
> : |------+------+------+------+------|
> : | 0.03 | 0.28 | 0.52 | 0.74 | 1.00 |
> : #+END_ORG
>
> The output exported to HTML can be quite nice.
>
> #+RESULTS:
> #+BEGIN_ORG
> #+CAPTION: Quantiles of 100 random numbers
> |   0% |  25% |  50% |  75% | 100% |
> |------+------+------+------+------|
> | 0.03 | 0.28 | 0.52 | 0.74 | 1.00 |
> #+END_ORG
>
> ### END SNIP ###### END SNIP ###### END SNIP ###
>
> ... As you can see, this code is statically "rigged" to export in such
> a way that it looks like it is working with R. When I try to make the
> code live by removing the markup as shown below ...
>
> #+BEGIN_SRC R :results output org
>   library(ascii)
>   a <- runif(100)
>   c <- "Quantiles of 100 random numbers"
>   b <- ascii(quantile(a),header=T,include.colnames=T,caption=c)
>   print(b,type="org")
>   rm(a,b,c)
> #+END_SRC
>
> The html produced by ...
>
> C-c C-e h h
>
> ... contains the fontified source code, but no table.
>
> ... C-c C-c on the code block produces these results ...
>
> #+RESULTS:
> #+BEGIN_SRC org
> ,#+CAPTION: Quantiles of 100 random numbers
> | 0%   | 25%  | 50%  | 75%  | 100% |
> |------+------+------+------+------|
> | 0.02 | 0.30 | 0.49 | 0.70 | 0.99 |
> #+END_SRC
>
> By trial and error, I discovered that if I change the header arguments
> as shown below ...
>
> #+BEGIN_SRC R :results output raw :exports results
>   library(ascii)
>   a <- runif(100)
>   c <- "Quantiles of 100 random numbers"
>   b <- ascii(quantile(a),header=T,include.colnames=T,caption=c)
>   print(b,type="org")
>   rm(a,b,c)
> #+END_SRC
>
> ... this produces a table in HTML that matches the table produced by
> the static code.
>
> ... C-c C-c on this code block produces these results ...
>
> #+RESULTS:
> #+CAPTION: Quantiles of 100 random numbers
> | 0%   | 25%  | 50%  | 75%  | 100% |
> |------+------+------+------+------|
> | 0.03 | 0.25 | 0.57 | 0.79 | 0.99 |
>
> Can someone tell me if this is how it is supposed to work?
>

Yup. I think you stumbled on a "bug" (though probably just more of an
oversight). I looked around a bit for the default babel header arguments
and think this looks accurate:
-
http://orgmode.org/manual/System_002dwide-header-arguments.html#System_002dwide-header-arguments

This, with nothing set for `:exports something`, the default is `:exports
code`.

What you did instead is correct -- you want to export results. I get the
same behavior: code only with no value set, results with `:exports results`
added. To "patch," that page, you would follow the procedure for
contributing to Worg:
- http://orgmode.org/worg/worg-git.html

You submit a key to Bastien, clone Worg, edit the file, and push your
changes.


Best regards,
John


>
> If so, how do I go about submiting a patch to ...
>
> http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.org
>
> Thanks,
> regcl
>
>

[-- Attachment #2: Type: text/html, Size: 5381 bytes --]

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

end of thread, other threads:[~2014-01-14  2:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-14  2:09 export from R to tables, possible correction to ob-doc-R.org regcl
2014-01-14  2:27 ` Thomas S. Dye
2014-01-14  2:29 ` John Hendy

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