Skip to content

Instantly share code, notes, and snippets.

@carlohamalainen
Created August 3, 2011 23:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlohamalainen/1124157 to your computer and use it in GitHub Desktop.
Save carlohamalainen/1124157 to your computer and use it in GitHub Desktop.
Run ggplot2 from Clojure using rincanter
; http://carlo-hamalainen.net/blog/2011/08/04/ggplot2-from-clojure
; To dump the plot to a file:
(use '(com.evocomputing rincanter)) ; https://github.com/jolby/rincanter
(r-eval "library(ggplot2)")
(r-eval-raw "qplot(rating, data=movies, geom=\"histogram\")") ; see http://had.co.nz/ggplot2/geom_histogram.html
(r-eval "ggsave('histogram-example.png')")
; To display on your screen (Unix example; see rincanter docs for alternatives to x11() call)
(use '(com.evocomputing rincanter))
(r-eval "x11()")
(r-eval "library(ggplot2)")
(r-eval-raw "p = qplot(rating, data=movies, geom=\"histogram\")")
(r-eval-raw "print(p)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment