Skip to content

svarcheg/rincanter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to Rincanter!

About

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.

Installation

Install R for your platform

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

Install and launch Rserve

From R execute following lines:

install.packages("Rserve")
library(Rserve)
Rserve()

Add rincanter dependency to project.clj

[svarcheg/rincanter "0.0.1-SNAPSHOT"]

Example Usage

The main entry points are the functions:

r-eval

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\")")

with-r-eval

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

Documentation

API Documentation

API Documentation for rincanter is located at: Rincanter API

About

Use Rserve to call R from Clojure and Incanter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Clojure 60.0%
  • HTML 40.0%