From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hendy Subject: Re: export from R to tables, possible correction to ob-doc-R.org Date: Mon, 13 Jan 2014 20:29:15 -0600 Message-ID: References: <87ppnve2l9.fsf@channing.harvard.edu> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b5d340c6ba71104efe4f509 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2tkn-0008Dr-CR for emacs-orgmode@gnu.org; Mon, 13 Jan 2014 21:29:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2tkj-00007g-69 for emacs-orgmode@gnu.org; Mon, 13 Jan 2014 21:29:21 -0500 Received: from mail-oa0-x229.google.com ([2607:f8b0:4003:c02::229]:35124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2tki-00007R-U6 for emacs-orgmode@gnu.org; Mon, 13 Jan 2014 21:29:17 -0500 Received: by mail-oa0-f41.google.com with SMTP id i4so8079618oah.28 for ; Mon, 13 Jan 2014 18:29:16 -0800 (PST) In-Reply-To: <87ppnve2l9.fsf@channing.harvard.edu> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: regcl Cc: emacs-orgmode --047d7b5d340c6ba71104efe4f509 Content-Type: text/plain; charset=UTF-8 On Mon, Jan 13, 2014 at 8:09 PM, regcl 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 > > --047d7b5d340c6ba71104efe4f509 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable



On Mon, Jan 13, 2014 at 8:09 PM, regcl <regcl@channing.ha= rvard.edu> wrote:
I was looking for an example of the export of R data frame= s 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-mod= e/lisp/)

Here is the problematic code ...

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

: #+BEGIN_SRC R :results output org
: =C2=A0library(ascii)
: =C2=A0a <- runif(100)
: =C2=A0c <- "Quantiles of 100 random numbers"
: =C2=A0b <- ascii(quantile(a),header=3DT,include.colnames=3DT,caption= =3Dc)
: =C2=A0print(b,type=3D"org")
: =C2=A0rm(a,b,c)
: #+END_SRC
:
: #+RESULTS:
: #+BEGIN_ORG
: #+CAPTION: Quantiles of 100 random numbers
: | 0% =C2=A0 | 25% =C2=A0| 50% =C2=A0| 75% =C2=A0| 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
| =C2=A0 0% | =C2=A025% | =C2=A050% | =C2=A075% | 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
=C2=A0 library(ascii)
=C2=A0 a <- runif(100)
=C2=A0 c <- "Quantiles of 100 random numbers"
=C2=A0 b <- ascii(quantile(a),header=3DT,include.colnames=3DT,caption=3D= c)
=C2=A0 print(b,type=3D"org")
=C2=A0 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% =C2=A0 | 25% =C2=A0| 50% =C2=A0| 75% =C2=A0| 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
=C2=A0 library(ascii)
=C2=A0 a <- runif(100)
=C2=A0 c <- "Quantiles of 100 random numbers"
=C2=A0 b <- ascii(quantile(a),header=3DT,include.colnames=3DT,caption=3D= c)
=C2=A0 print(b,type=3D"org")
=C2=A0 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% =C2=A0 | 25% =C2=A0| 50% =C2=A0| 75% =C2=A0| 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:
-=C2=A0http://orgmode.org/manual/Sys= tem_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 corre= ct -- you want to export results. I get the same behavior: code only with n= o value set, results with `:exports results` added. To "patch," t= hat page, you would follow the procedure for contributing to Worg:

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


Best regards,
John
=C2=A0

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


--047d7b5d340c6ba71104efe4f509--