Welcome to Rincanter!
Main difference from original rincanter is that this version does not require playing with native libraries as it uses a socket connection to the R interpreter. As the original version, it also offers translation between Clojure and Incanter datatypes and R datatypes such as R dataframe to Incanter dataset.
The directions for installing R are outside the scope of this document, but R is well supported on most platforms, and has great documentation: R Project Page
From R execute following lines:
install.packages("Rserve") library(Rserve) Rserve()
[svarcheg/rincanter "0.0.1-SNAPSHOT"]
The main entry points are the functions:
You can play around with Clojure/Incanter and R in the same REPL session:
(use '(rincanter core)) (r-eval "data(iris)") ;;eval's the iris dataframe object, converts into ;;incanter dataset (r-eval "iris") ;;create vector on R side (r-eval "vec_in_r = c(1,2,3)") ;;now retrieve it, converting to Clojure vector (r-get "vec_in_r")
plotting:
(use '(rincanter core)) (r-eval "data(iris)") ;;initialize the R graphics device for your system: ;;For Mac OS X (r-eval "quartz()") ;;windows: (r-eval "windows()") ;;unix/linux (r-eval "x11()") ;;create the plot using values from the iris dataset (r-eval "plot(Sepal.Length ~ Sepal.Width, data = iris)") ;;alter this existing plot (r-eval "title(main = \"Iris Sepal Measurements\")")
Using with-r-eval, it is even easier. Within this form, all forms enclosed in parenthesis are evaluated as normal Clojure forms, strings are evaluated in R using r-eval:
(use '(rincanter core)) (with-r-eval "data(iris)" ;;eval's the iris dataframe object, converts into ;;incanter dataset "iris" ;;create vector on R side "vec_in_r = c(1,2,3)" ;;now retrieve it, converting to Clojure vector (r-get "vec_in_r"))
API Documentation for rincanter is located at: Rincanter API