emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <ndokos@gmail.com>
To: emacs-orgmode@gnu.org
Subject: R code block on Worg
Date: Tue, 09 Apr 2013 20:18:18 -0400	[thread overview]
Message-ID: <25652.1365553098@pierrot.dokosmarshall.org> (raw)

The example I used earlier came from

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

Here it is again for reference:

--8<---------------cut here---------------start------------->8---
#+name: r-with-ggplot2
#+begin_src R :results output graphics :var tbl=foo :file r/foo-output.png :width 400 :height 300
  library(ggplot2)
  res <- ggplot(tbl, aes(a_foo_var))
  res + geom_histogram(aes(y=..density..)) +
  geom_density(weight=2) + xlab("A foo variable")
#+end_src
--8<---------------cut here---------------end--------------->8---

Just to be clear, my R knowledge is less than \epsilon.
I was trying to get this to work and I had a few problems:

o It uses a table named "foo" as input, which does not appear on the
  page at all.  So I added a stupid table of my own. The only trouble is
  I'm not sure what the code does with it.

o It uses the ggplot2 library (and the earlier examples use the ascii
  library) which I didn't have on my system.  I was trying to find a
  package on Ubuntu to get these, but I couldn't. I finally stumbled
  across the R way of installing libraries:

  > install.packages("ggplot2")

  at the R prompt.

o Then R complained about a_foo_var:

  + Error in eval(expr, envir, enclos) : object 'a_foo_var' not found

  So I just added a dummy a_foo_var <- 3 into the block to get it going,
  but again, I have no idea what the code does with it.

o Finally, there is no graphic output on the page that I could compare
  with what I got and no explanatory description. I *could* go and learn
  some R and be a better person for it too, but I just wanted a little
  taste and this example was a bit too troublesome for me.

Could somebody knowledgeable in R fix the example and perhaps provide
some explanatory comments? Or provide suitable handholding?  Given the
latter, I'd be happy to make the changes necessary. Or perhaps this is
not the best example for that page and a simpler example could be given
instead?

Thoughts?

Thanks,
Nick





  

             reply	other threads:[~2013-04-10  0:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-10  0:18 Nick Dokos [this message]
2013-04-10  1:02 ` R code block on Worg Jay Kerns
2013-04-10  3:26   ` Nick Dokos

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=25652.1365553098@pierrot.dokosmarshall.org \
    --to=ndokos@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).