emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] R code block on Worg


From: Nick Dokos
Subject: [O] R code block on Worg
Date: Tue, 09 Apr 2013 20:18:18 -0400

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 via email to

[Prev in Thread] Current Thread [Next in Thread]