- Overview
- Getting started with Clojure
- Getting started with Incanter
- Documentation and examples
- Building Incanter
- Dependencies
Incanter is a Clojure-based, R-like statistical computing and graphics environment for the JVM. At the core of Incanter are the Parallel Colt numerics library, a multithreaded version of Colt, and the JFreeChart charting library, as well as several other Java and Clojure libraries.
The motivation for creating Incanter is to provide a JVM-based statistical computing and graphics platform with R-like semantics and interactive-programming environment. Running on the JVM provides access to the large number of existing Java libraries for data access, data processing, and presentation. Clojure’s seamless integration with Java makes leveraging these libraries much simpler than is possible in R, and Incanter’s R-like semantics makes statistical programming much simpler than is possible in pure Java.
Motivation for a Lisp-based R-like statistical environment can be found in the paper Back to the Future: Lisp as a Base for a Statistical Computing System by Ihaka and Lang (2008). Incanter is also inspired by the now dormant Lisp-Stat (see the special volume in the Journal of Statistical Software on Lisp-Stat: Past, Present, and Future from 2005).
Motivation for a JVM-based Lisp can be found at the Clojure website, and screencasts of several excellent Clojure talks by the language’s creator, Rich Hickey, can be found at clojure.blip.tv.
For a great introduction to programming in Clojure, read Clojure – Functional Programming for the JVM. by R. Mark Volkmann. For an even more extensive introduction, get the newly released book Programming Clojure by Stuart Halloway.
Other Clojure resources
- Clojure website
- Getting Started with Clojure
- Clojure Google group
- clojure.blip.tv
- Clojure Programming Wikibook
- Learning Clojure Wikibook
Start by visiting the Incanter website for an overview, checkout the documentation page for a listing of HOW-TOs and examples, and then download a pre-built version of either the latest build of Incanter, which includes all the necessary dependencies, and unpack the file (if you would like to build it from source, read Building Incanter).
Start the Clojure shell (aka the REPL) from the Incanter directory: script/repl
or script\repl.bat
on Windows. NOTE: The lein repl task uses Clojure 1.1, and Incanter 1.2.x requires Clojure 1.2, so use the repl script instead of lein.
NOTE: If you want the latest version of Incanter, clone the repository with git, and run lein deps
to download the necessary dependencies before using script/repl
or script/swank
(or script\repl.bat
, script\swank.bat
).
From the Clojure shell, load the Incanter libraries:
user=> (use '(incanter core stats charts))
Try an example: sample 1,000 values from a standard-normal distribution and view a histogram:
user=> (view (histogram (sample-normal 1000)))
Try another simple example, a plot of the sine function over the range -4 to 4:
user=> (view (function-plot sin -10 10))
The online documentation for most Incanter functions contain usage examples. The documentation can be viewed using Clojure’s doc
function. For example, to view the documentation and usage examples for the linear-model
function, call (doc linear-model)
from the Clojure shell. Use (find-doc "search term")
to search the online documentation from the Clojure shell. The API documentation can also be found at http://liebke.github.com/incanter.
More Incanter examples
- See the Incanter blog
- See Incanter wiki
- See the
examples/
directory for additional usage examples.script/clj examples/run_prob_plots.clj
to generate example probability distribution plots
The following documentation covers the Incanter and Clojure APIs and the APIs of the underlying java libraries.
Incanter documentation
Related API documentation
To build and test Incanter, you will need to have Leiningen and git installed:
- First, clone the Incanter Github repository:
git clone git://github.com/liebke/incanter.git
- cd into the incanter directory
- use Leiningen to download the necessary dependencies:
lein deps
- You can now use the
script/repl
andscript/swank
scripts (or on Windowsrepl.bat
andswank.bat
) to start a REPL and Swank server respectively. - If you want to run the tests for each of Incanter’s modules, use
script/test
- Each of Incanter’s modules are independent Leiningen projects. Just cd into modules/incanter-* and use Leiningen to build each one as a standalone library.
script/install
uses Leiningen to build all the modules and install them in your local ~/.m2 repository.
- Clojure
- Clojure-Contrib
- Parallel Colt
- Netlib-Java (included with Parallel Colt)
- JFreeChart
- OpenCSV
- iText
- Congomongo
- Clojure-json
- JLine