From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shiyuan Subject: Babel-R TBLFM example Date: Tue, 24 Jun 2014 23:55:46 -0700 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e01177721dae64604fca3905b Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55880) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wzh7V-0005o4-Mq for emacs-orgmode@gnu.org; Wed, 25 Jun 2014 02:55:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wzh7U-0007Sb-7v for emacs-orgmode@gnu.org; Wed, 25 Jun 2014 02:55:49 -0400 Received: from mail-vc0-x22f.google.com ([2607:f8b0:400c:c03::22f]:40444) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wzh7U-0007ST-2N for emacs-orgmode@gnu.org; Wed, 25 Jun 2014 02:55:48 -0400 Received: by mail-vc0-f175.google.com with SMTP id hy4so1455992vcb.34 for ; Tue, 24 Jun 2014 23:55:47 -0700 (PDT) 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: emacs-orgmode@gnu.org --089e01177721dae64604fca3905b Content-Type: text/plain; charset=UTF-8 Hi all, I am looking at the Babel R example in http://orgmode.org/worg/org-tutorials/org-R/org-R.html This short example show how to use code block in Org Tables. The example first makes an org-mode table, which I can follow and reproduce the result: #+name: tbl-example-data() #+begin_src R runif(n=5, min=0, max=1) #+end_src #+RESULTS: tbl-example-data | 0.118510485393927 | | 0.742342338664457 | | 0.438421099446714 | | 0.0867570964619517 | | 0.604204315226525 | Then it defines r source code block and use TBLFM #+name: R-mean(x) #+begin_src R mean(x) #+end_src #+RESULTS: R-mean #+tblname: summaries | mean | |--------| | #ERROR | #+TBLFM: @2$1='(sbe "R-mean" (x "tbl-example-data()")) When I export to html(C-c C-e h o), the #+TBLFM seems to be ignored and shows no effect. When I place my cursor in the table and recalculate the table formula using C-u C-c C-c in the table. I got an error as shown above. In the *Message* buffer, I can see the following messages. byte-code: Beginning of buffer [8 times] Re-applying formulas to full table... Re-applying formula to field: @2$1 Re-applying formulas to full table...(line 1) Re-applying formula to field: @2$1 Re-applying formulas to 1 lines...done Re-applying formulas...done [2 times] Any steps I missed? I am using org mode 8.2.6 Also, I found this tutorial for org-R http://orgmode.org/worg/org-tutorials/org-R/org-R.html, however, the org-R-apply function seems no longer available in my org mode 8.2.6. Is org-R supposed to be deprecated? Thanks. Shiyuan --089e01177721dae64604fca3905b Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi all,=C2=A0
=C2=A0 =C2=A0 I am looking at the Babel = R example in=C2=A0

This short example show how to use code block in Org Tables.=C2= =A0
The example first makes an org-mode table, which I can follow= and reproduce the result:=C2=A0

#+name: tbl-= example-data()
#+begin_src R=C2=A0
runif(n=3D5, min=3D0, max=3D1)
#+end_src

#+RESULTS: tbl-example-data
|= =C2=A00.118510485393927 |
| =C2=A00.742342338664457 |
= | =C2=A00.438421099446714 |
| 0.0867570964619517 |
| =C2=A00.604204315226525 |

Then it defines r source code block and use TBLFM=C2= =A0

#+name: R-mean(x)
#+begin_src R= =C2=A0
mean(x)
#+end_src

#+RESULTS: R-mean=

#+tblname: summaries
| mean =C2=A0 |
|--------|
| #ERROR |
#+TBLFM: @2$1=3D'(sbe= "R-mean" (x "tbl-example-data()"))

When I export to html(C-c C-e h o), the =C2=A0#+T= BLFM seems to be ignored and shows =C2=A0no effect. When I place my cursor = in the table and recalculate the table formula using C-u C-c C-c in the tab= le. I got an error as shown above. =C2=A0 In the *Message* buffer, I can se= e the following messages.
byte-code: Beginning of buffer [8 times]
Re-applying fo= rmulas to full table...
Re-applying formula to field: @2$1
<= div>Re-applying formulas to full table...(line 1)
Re-applying for= mula to field: @2$1
Re-applying formulas to 1 lines...done
Re-applying formulas.= ..done [2 times]

Any steps I missed? I am us= ing org mode 8.2.6

Also, I found this tutorial for= org-R h= ttp://orgmode.org/worg/org-tutorials/org-R/org-R.html, however, the org= -R-apply function seems no longer available in my org mode 8.2.6. Is org-R = supposed to be deprecated?=C2=A0

Thanks.=C2=A0

Shiyuan=C2=A0

=C2=A0=C2=A0
--089e01177721dae64604fca3905b-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Babel-R TBLFM example Date: Mon, 28 Jul 2014 15:21:16 +0200 Message-ID: <8738dl1jm7.fsf@bzg.ath.cx> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBofp-0007X6-VR for emacs-orgmode@gnu.org; Mon, 28 Jul 2014 13:25:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XBofb-0005sG-5F for emacs-orgmode@gnu.org; Mon, 28 Jul 2014 13:25:21 -0400 Received: from mail-s76.mailgun.info ([184.173.153.204]:51196) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBofb-0005Un-2g for emacs-orgmode@gnu.org; Mon, 28 Jul 2014 13:25:07 -0400 In-Reply-To: (Shiyuan's message of "Tue, 24 Jun 2014 23:55:46 -0700") 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: Shiyuan Cc: emacs-orgmode@gnu.org Hi Shiyuan, Shiyuan writes: > Also, I found this tutorial for org-R http://orgmode.org/worg/ > org-tutorials/org-R/org-R.html, however, the org-R-apply function > seems no longer available in my org mode 8.2.6. Is org-R supposed to > be deprecated? No, but it's moving. Since ob-R.el is perhaps one of the most useful Babel library out there, we need to document the changes carefully in etc/ORG-NEWS. -- Bastien From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shiyuan Subject: Re: Babel-R TBLFM example Date: Mon, 28 Jul 2014 23:15:21 -0700 Message-ID: References: <8738dl1jm7.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113382b6e8ccf904ff4ef699 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XC0h2-0007Bu-DI for emacs-orgmode@gnu.org; Tue, 29 Jul 2014 02:15:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XC0h0-0006kX-Vl for emacs-orgmode@gnu.org; Tue, 29 Jul 2014 02:15:24 -0400 In-Reply-To: <8738dl1jm7.fsf@bzg.ath.cx> 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: Bastien Cc: "emacs-orgmode@gnu.org" --001a113382b6e8ccf904ff4ef699 Content-Type: text/plain; charset=UTF-8 Thanks Bastien. I see ob-R.el from org-mode repos has been updated. So is the org-R from git-repos ready to use? Could you suggest a good place to start learning the new org-R? The source file ob-R.el? Shiyuan On Mon, Jul 28, 2014 at 6:21 AM, Bastien wrote: > Hi Shiyuan, > > Shiyuan writes: > > > Also, I found this tutorial for org-R http://orgmode.org/worg/ > > org-tutorials/org-R/org-R.html, however, the org-R-apply function > > seems no longer available in my org mode 8.2.6. Is org-R supposed to > > be deprecated? > > No, but it's moving. Since ob-R.el is perhaps one of the most useful > Babel library out there, we need to document the changes carefully in > etc/ORG-NEWS. > > -- > Bastien > --001a113382b6e8ccf904ff4ef699 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Thanks Bastien. I see ob-R.el from org-mode repos has been= updated. So is the org-R from git-repos ready to use? Could you suggest = =C2=A0a good place to start learning the new org-R? The source file ob-R.el= ? =C2=A0

Shiyuan=C2=A0


=
On Mon, Jul 28, 2014 at 6:21 AM, Bastien <bzg@gnu.org= > wrote:
Hi Shiyuan,

Shiyuan <gshy2014@gmail.com>= ; writes:

> Also, I found this tutorial for org-R http://orgmode.org/worg/
> org-tutorials/org-R/org-R.html, however, the org-R-apply function
> seems no longer available in my org mode 8.2.6. Is org-R supposed to > be deprecated?

No, but it's moving. =C2=A0Since ob-R.el is perhaps one of the mo= st useful
Babel library out there, we need to document the changes carefully in
etc/ORG-NEWS.

--
=C2=A0Bastien

--001a113382b6e8ccf904ff4ef699-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Re: Babel-R TBLFM example Date: Tue, 29 Jul 2014 15:20:31 +0200 Message-ID: <8761igfgio.fsf@bzg.ath.cx> References: <8738dl1jm7.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XC7Ka-0007jQ-No for emacs-orgmode@gnu.org; Tue, 29 Jul 2014 09:20:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XC7KT-00065q-Rf for emacs-orgmode@gnu.org; Tue, 29 Jul 2014 09:20:40 -0400 Received: from mail-s76.mailgun.info ([184.173.153.204]:46044) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XC7KT-0005Y5-O9 for emacs-orgmode@gnu.org; Tue, 29 Jul 2014 09:20:33 -0400 In-Reply-To: (Shiyuan's message of "Mon, 28 Jul 2014 23:15:21 -0700") 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: Shiyuan Cc: "emacs-orgmode@gnu.org" Hi Shiyuan, Shiyuan writes: > Thanks Bastien. I see ob-R.el from org-mode repos has been updated. > So is the org-R from git-repos ready to use? Could you suggest  a > good place to start learning the new org-R? The source file ob-R.el? The recent committers to ob-R.el we be more in a position to help here but yes, reading the source is certainly a good start. I hope we will have a clear picture of what changed in ob-R.el in 8.3, together with updated tutorials. Best, -- Bastien From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shiyuan Subject: Re: Babel-R TBLFM example Date: Sun, 24 Aug 2014 16:02:33 -0700 Message-ID: References: <8738dl1jm7.fsf@bzg.ath.cx> <8761igfgio.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c28620c8ab5405016810e3 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34132) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XLgo0-00080d-Oe for emacs-orgmode@gnu.org; Sun, 24 Aug 2014 19:02:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XLgnz-00033s-Ax for emacs-orgmode@gnu.org; Sun, 24 Aug 2014 19:02:36 -0400 In-Reply-To: <8761igfgio.fsf@bzg.ath.cx> 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: Bastien Cc: "emacs-orgmode@gnu.org" --001a11c28620c8ab5405016810e3 Content-Type: text/plain; charset=UTF-8 I am looking at a simpler example, the pie-chart example as in this link: http://orgmode.org/worg/org-contrib/babel/intro.html#literate-programming This example(src code attached in the end) first generates a table by a shell command and then run a R one-liner which uses the table. However, when the R code is evaluated, I got an error about the object dirs not found. This is what I got in the buffer running R: ------------------------------- options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', show.error.locations=TRUE) > Error in pie(dirs[, 1], labels = dirs[, 2]) (from test-org-babe-meta-programming.org@24170fIx#1) : object 'dirs' not found ----------------------------------------------- It looks like that the conversion is wrong. When I run `org-babel-expand-src-block` on the R source code, I don't see the R object dirs is expanded to anything. I don't understand how the conversion works, and how Babel passes the table to R. Any explanation is appreciated. Which function/file should I look at? Are there working examples for passing a table to R? Thanks. Shiyuan ------------------------------ #+name: directories #+begin_src shell :results replace cd ~ && du -sc * |grep -v total #+end_src #+RESULTS: directories | 8 | #*message*-20140319-231047# | | 1168376 | Documents | | 9952288 | Downloads | | 8 | xmodmap2~ | #+name: directory-pie-chart(dirs = directories) #+begin_src R :session R-pie-example :file ~/tmp/dirs.png pie(dirs[,1], labels = dirs[,2]) #+end_src On Tue, Jul 29, 2014 at 6:20 AM, Bastien wrote: > Hi Shiyuan, > > Shiyuan writes: > > > Thanks Bastien. I see ob-R.el from org-mode repos has been updated. > > So is the org-R from git-repos ready to use? Could you suggest a > > good place to start learning the new org-R? The source file ob-R.el? > > The recent committers to ob-R.el we be more in a position to help here > but yes, reading the source is certainly a good start. > > I hope we will have a clear picture of what changed in ob-R.el in 8.3, > together with updated tutorials. > > Best, > > -- > Bastien > --001a11c28620c8ab5405016810e3 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I am looking at a simpler example, the pie-chart example a= s in this link:=C2=A0http://orgmode.org/worg/org-contrib/babel/i= ntro.html#literate-programming

This example(src code attached in the end) first generates a= table by a shell command and then run a R one-liner which uses the table. = =C2=A0However, when the R code is evaluated, I got an error about the objec= t dirs not found. =C2=A0This is what I got in the buffer running R:=C2=A0
-------------------------------
options(STERM=3D'iE= SS', str.dendrogram.last=3D"'", editor=3D'emacsclient= ', show.error.locations=3DTRUE)
>=C2=A0
Error in= pie(dirs[, 1], labels =3D dirs[, 2]) (from test-org-babe-meta-programming.= org@24170fIx#1) : object 'dirs' not found
-----------------------------------------------

It looks like that the conversion is wrong. =C2=A0When I run `org-bab= el-expand-src-block` on the R source code, I don't see the R object dir= s is expanded to anything. I don't understand how the conversion works,= and how Babel passes the table to R. Any explanation is appreciated. Which= function/file should I look at? Are there working examples for passing a t= able to R? Thanks.=C2=A0

Shiyuan=C2=A0


------------------------------
#+name: directories
#= +begin_src shell :results replace
=C2=A0 cd ~ && du -sc *= |grep -v total
#+end_src

#+RESULTS: dir= ectories
| =C2=A0 =C2=A0 =C2=A0 8 | #*message*-20140319-231047# |
| 1= 168376 | Documents =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 |
| 9952288 | Downloads =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 |
| =C2=A0 =C2=A0 =C2=A0 8 | xmodmap= 2~ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 |

#+name: directory-pie-chart(dirs =3D directories)
#+be= gin_src R :session R-pie-example :file ~/tmp/dirs.png
=C2=A0 pie(= dirs[,1], labels =3D dirs[,2])
#+end_src
<= div class=3D"gmail_extra">

On Tue, Jul 29, 2014 at 6:20 AM, Bastien= <bzg= @gnu.org> wrote:
Hi Shiyuan,

Shiyuan <gshy2014@gmail.com>= ; writes:

> Thanks Bastien. I see ob-R.el from org-mode repo= s has been updated.
> So is the org-R from git-repos ready to use? Could you suggest =C2=A0a=
> good place to start learning the new org-R? The source file ob-R.el?
The recent committers to ob-R.el we be more in a position to help her= e
but yes, reading the source is certainly a good start.

I hope we will have a clear picture of what changed in ob-R.el in 8.3,
together with updated tutorials.

Best,

--
=C2=A0Bastien

--001a11c28620c8ab5405016810e3-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastien Vauban Subject: Re: Babel-R TBLFM example Date: Mon, 25 Aug 2014 09:51:10 +0200 Message-ID: <861ts5knwx.fsf@somewhere.org> References: <8738dl1jm7.fsf@bzg.ath.cx> <8761igfgio.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain Return-path: 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-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Shiyuan wrote: > I am looking at a simpler example, the pie-chart example as in this link: > http://orgmode.org/worg/org-contrib/babel/intro.html#literate-programming > > This example(src code attached in the end) first generates a table by a > shell command and then run a R one-liner which uses the table. However, > when the R code is evaluated, I got an error about the object dirs not > found. This is what I got in the buffer running R: > ------------------------------- > options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', > show.error.locations=TRUE) >> > Error in pie(dirs[, 1], labels = dirs[, 2]) (from > test-org-babe-meta-programming.org@24170fIx#1) : object 'dirs' not found > ----------------------------------------------- > > It looks like that the conversion is wrong. When I run > `org-babel-expand-src-block` > on the R source code, I don't see the R object dirs is expanded to > anything. I don't understand how the conversion works, and how Babel passes > the table to R. Any explanation is appreciated. Which function/file should > I look at? Are there working examples for passing a table to R? Thanks. > > #+name: directories > #+begin_src shell :results replace > cd ~ && du -sc * |grep -v total > #+end_src > > #+RESULTS: directories > | 8 | #*message*-20140319-231047# | > | 1168376 | Documents | > | 9952288 | Downloads | > | 8 | xmodmap2~ | > > #+name: directory-pie-chart(dirs = directories) > #+begin_src R :session R-pie-example :file ~/tmp/dirs.png > pie(dirs[,1], labels = dirs[,2]) > #+end_src AFAICT, the arguments to code blocks may not be defined and set in the `name' line anymore: this must be done on the `begin_src' line. So, the following should work: #+name: directory-pie-chart #+begin_src R :var dirs=directories :session R-pie-example :file ~/tmp/dirs.png pie(dirs[,1], labels = dirs[,2]) #+end_src Best regards, Seb -- Sebastien Vauban From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shiyuan Subject: Re: Babel-R TBLFM example Date: Mon, 25 Aug 2014 23:18:25 -0700 Message-ID: References: <8738dl1jm7.fsf@bzg.ath.cx> <8761igfgio.fsf@bzg.ath.cx> <861ts5knwx.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d0434bea664044905018245ad Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50630) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMA5M-0003AX-DN for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 02:18:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMA5K-0005t3-Ob for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 02:18:28 -0400 Received: from mail-wg0-x22d.google.com ([2a00:1450:400c:c00::22d]:59672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMA5K-0005sr-Ef for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 02:18:26 -0400 Received: by mail-wg0-f45.google.com with SMTP id x12so13834437wgg.28 for ; Mon, 25 Aug 2014 23:18:25 -0700 (PDT) In-Reply-To: <861ts5knwx.fsf@somewhere.org> 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 Cc: "emacs-orgmode@gnu.org" --f46d0434bea664044905018245ad Content-Type: text/plain; charset=UTF-8 Yes, it works. Thanks, Sebastien. Shiyuan On Mon, Aug 25, 2014 at 12:51 AM, Sebastien Vauban wrote: > Shiyuan wrote: > > I am looking at a simpler example, the pie-chart example as in this link: > > > http://orgmode.org/worg/org-contrib/babel/intro.html#literate-programming > > > > This example(src code attached in the end) first generates a table by a > > shell command and then run a R one-liner which uses the table. However, > > when the R code is evaluated, I got an error about the object dirs not > > found. This is what I got in the buffer running R: > > ------------------------------- > > options(STERM='iESS', str.dendrogram.last="'", editor='emacsclient', > > show.error.locations=TRUE) > >> > > Error in pie(dirs[, 1], labels = dirs[, 2]) (from > > test-org-babe-meta-programming.org@24170fIx#1) : object 'dirs' not found > > ----------------------------------------------- > > > > It looks like that the conversion is wrong. When I run > > `org-babel-expand-src-block` > > on the R source code, I don't see the R object dirs is expanded to > > anything. I don't understand how the conversion works, and how Babel > passes > > the table to R. Any explanation is appreciated. Which function/file > should > > I look at? Are there working examples for passing a table to R? Thanks. > > > > #+name: directories > > #+begin_src shell :results replace > > cd ~ && du -sc * |grep -v total > > #+end_src > > > > #+RESULTS: directories > > | 8 | #*message*-20140319-231047# | > > | 1168376 | Documents | > > | 9952288 | Downloads | > > | 8 | xmodmap2~ | > > > > #+name: directory-pie-chart(dirs = directories) > > #+begin_src R :session R-pie-example :file ~/tmp/dirs.png > > pie(dirs[,1], labels = dirs[,2]) > > #+end_src > > AFAICT, the arguments to code blocks may not be defined and set in the > `name' line anymore: this must be done on the `begin_src' line. > > So, the following should work: > > #+name: directory-pie-chart > #+begin_src R :var dirs=directories :session R-pie-example :file > ~/tmp/dirs.png > pie(dirs[,1], labels = dirs[,2]) > #+end_src > > Best regards, > Seb > > -- > Sebastien Vauban > > > --f46d0434bea664044905018245ad Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Yes, it works. Thanks, Sebastien.=C2=A0

Shiyuan=C2=A0


On Mon, Aug 25, 2014 at 12:51 AM, Sebastien Vauban <s= va-news@mygooglest.com> wrote:
Shiyuan wrote:
> I am looking at a simpler example, the pie-chart example as in this li= nk:
> http://orgmode.org/worg/org-contrib/babel= /intro.html#literate-programming
>
> This example(src code attached in the end) first generates a table by = a
> shell command and then run a R one-liner which uses the table.=C2=A0 H= owever,
> when the R code is evaluated, I got an error about the object dirs not=
> found.=C2=A0 This is what I got in the buffer running R:
> -------------------------------
> options(STERM=3D'iESS', str.dendrogram.last=3D"'"= ;, editor=3D'emacsclient',
> show.error.locations=3DTRUE)
>>
> Error in pie(dirs[, 1], labels =3D dirs[, 2]) (from
> test-org-babe-meta-programming.org@24170fIx#1) : object 'dirs'= not found
> -----------------------------------------------
>
> It looks like that the conversion is wrong.=C2=A0 When I run
> `org-babel-expand-src-block`
> on the R source code, I don't see the R object dirs is expanded to=
> anything. I don't understand how the conversion works, and how Bab= el passes
> the table to R. Any explanation is appreciated. Which function/file sh= ould
> I look at? Are there working examples for passing a table to R? Thanks= .
>
> #+name: directories
> #+begin_src shell :results replace
>=C2=A0 =C2=A0cd ~ && du -sc * |grep -v total
> #+end_src
>
> #+RESULTS: directories
> |=C2=A0 =C2=A0 =C2=A0 =C2=A08 | #*message*-20140319-231047# |
> | 1168376 | Documents=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0|
> | 9952288 | Downloads=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0|
> |=C2=A0 =C2=A0 =C2=A0 =C2=A08 | xmodmap2~=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
>
> #+name: directory-pie-chart(dirs =3D directories)
> #+begin_src R :session R-pie-example :file ~/tmp/dirs.png
>=C2=A0 =C2=A0pie(dirs[,1], labels =3D dirs[,2])
> #+end_src

AFAICT, the arguments to code blocks may not be defined and set in th= e
`name' line anymore: this must be done on the `begin_src' line.

So, the following should work:

=C2=A0 #+name: directory-pie-chart
=C2=A0 #+begin_src R :var dirs=3Ddirectories :session R-pie-example :file ~= /tmp/dirs.png
=C2=A0 =C2=A0 pie(dirs[,1], labels =3D dirs[,2])
=C2=A0 #+end_src

Best regards,
=C2=A0 Seb

--
Sebastien Vauban



--f46d0434bea664044905018245ad-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: tsd@tsdye.com (Thomas S. Dye) Subject: Re: Babel-R TBLFM example Date: Mon, 25 Aug 2014 20:57:10 -1000 Message-ID: References: <8738dl1jm7.fsf@bzg.ath.cx> <8761igfgio.fsf@bzg.ath.cx> <861ts5knwx.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:56756) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XMAhC-0002Zh-Pz for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 02:57:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XMAh5-0000M3-Bb for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 02:57:34 -0400 Received: from gproxy7-pub.mail.unifiedlayer.com ([70.40.196.235]:45872) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1XMAh5-0000KW-4G for emacs-orgmode@gnu.org; Tue, 26 Aug 2014 02:57:27 -0400 In-Reply-To: (Shiyuan's message of "Mon, 25 Aug 2014 23:18:25 -0700") 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: Shiyuan Cc: "emacs-orgmode@gnu.org" Aloha all, >> AFAICT, the arguments to code blocks may not be defined and set in the >> `name' line anymore: this must be done on the `begin_src' line. or, on a separate #+header: line. All the best, Tom -- Thomas S. Dye http://www.tsdye.com From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sebastien Vauban Subject: Re: Babel-R TBLFM example Date: Tue, 26 Aug 2014 09:23:36 +0200 Message-ID: <867g1vpvd3.fsf@somewhere.org> References: <8738dl1jm7.fsf@bzg.ath.cx> <8761igfgio.fsf@bzg.ath.cx> <861ts5knwx.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: 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-mXXj517/zsQ@public.gmane.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org Thomas S. Dye wrote: > Aloha all, > >>> AFAICT, the arguments to code blocks may not be defined and set in the >>> `name' line anymore: this must be done on the `begin_src' line. > > or, on a separate #+header: line. Indeed. I tend to forget to use that; thanks for mentioning it! Best regards, Seb -- Sebastien Vauban