From: Shiyuan <gshy2014@gmail.com>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Babel-R TBLFM example
Date: Mon, 25 Aug 2014 23:18:25 -0700 [thread overview]
Message-ID: <CAOm4EMvNB7Kv2hb4Y1PkM3mRK22w0qLAW8PL-b4iNzqhOoGT4g@mail.gmail.com> (raw)
In-Reply-To: <861ts5knwx.fsf@somewhere.org>
[-- Attachment #1: Type: text/plain, Size: 2240 bytes --]
Yes, it works. Thanks, Sebastien.
Shiyuan
On Mon, Aug 25, 2014 at 12:51 AM, Sebastien Vauban <sva-news@mygooglest.com>
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
>
>
>
[-- Attachment #2: Type: text/html, Size: 3184 bytes --]
next prev parent reply other threads:[~2014-08-26 6:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-25 6:55 Babel-R TBLFM example Shiyuan
2014-07-28 13:21 ` Bastien
2014-07-29 6:15 ` Shiyuan
2014-07-29 13:20 ` Bastien
2014-08-24 23:02 ` Shiyuan
2014-08-25 7:51 ` Sebastien Vauban
2014-08-26 6:18 ` Shiyuan [this message]
2014-08-26 6:57 ` Thomas S. Dye
2014-08-26 7:23 ` Sebastien Vauban
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=CAOm4EMvNB7Kv2hb4Y1PkM3mRK22w0qLAW8PL-b4iNzqhOoGT4g@mail.gmail.com \
--to=gshy2014@gmail.com \
--cc=emacs-orgmode@gnu.org \
/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).