emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* R code block on Worg
@ 2013-04-10  0:18 Nick Dokos
  2013-04-10  1:02 ` Jay Kerns
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Dokos @ 2013-04-10  0:18 UTC (permalink / raw)
  To: emacs-orgmode

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





  

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-04-10  3:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-10  0:18 R code block on Worg Nick Dokos
2013-04-10  1:02 ` Jay Kerns
2013-04-10  3:26   ` Nick Dokos

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).