How to Get Started with Incanter

Updated

Incanter is a Clojure-based, R-like platform for statistical computing and graphics. You can start using it in two ways: download a pre-built version or the source code and follow the getting started page, or add it as a dependency to an existing Clojure project through Clojars using Leiningen or Maven. The dependency route is the faster option if you already have a Clojure build set up; the standalone download makes more sense if you want an interactive environment without touching an existing project.

What Incanter Is

Incanter runs on the JVM and can be used either as a standalone, interactive data analysis environment or embedded within other analytics systems as a modular suite of libraries. It combines Clojure — a dynamically-typed, functional language — with Java libraries for numerics, charting, and visualization.

Its feature set covers:

  • Charting and visualization functions
  • Mathematical functions
  • Statistical functions
  • Matrix and linear algebra functions
  • Data manipulation functions
  • Interactive, dynamic, functional statistical programming on the JVM

Under the hood, Incanter builds on the Parallel Colt numerics library (a multithreaded version of Colt), the JFreeChart charting library, and the Processing visualization library, among other Java and Clojure libraries. Because Clojure integrates directly with Java, Incanter can leverage these libraries more simply than R can, while its R-like semantics and interactive shell keep statistical programming simpler than pure Java would allow.

Option 1: Download and Run Incanter Directly

Use this path if you want to explore Incanter as a standalone environment before wiring it into a project.

  1. Get the code. Download a pre-built version of Incanter, or pull the latest source code from the GitHub repository.
  2. Follow the getting started page. The project points new users there for setup instructions.
  3. Work interactively. Incanter's interactive shell is where the R-like, dynamic style of statistical programming happens.

The expected result is a working interactive environment where you can load data, run statistical functions, and produce charts.

Option 2: Add Incanter as a Project Dependency

Use this path if you are building a Clojure application and want Incanter embedded as a library suite. Incanter is hosted on Clojars for users of Leiningen or Maven-based tools.

With Leiningen, add a single line to your project.clj dependencies.

With Maven, add a few lines of XML to your pom.xml.

The expected result is that Incanter's libraries resolve as part of your normal build, and you can call its statistical and charting functions from your own code.

Choosing Between the Two

Situation Better starting point
You want to try statistical computing and graphics interactively Pre-built download + getting started page
You already maintain a Clojure project Clojars dependency via Leiningen or Maven
You want to embed analytics into a larger system Clojars dependency
You want to read or modify Incanter itself Source code from GitHub

Background Worth Knowing

Incanter's design draws on two older lines of work: the paper Back to the Future: Lisp as a Base for a Statistical Computing System by Ihaka and Lang (2008), and the now-dormant Lisp-Stat system (see the 2005 special volume of the Journal of Statistical Software on Lisp-Stat). If you are coming from R, the R-like semantics will feel familiar; if you are coming from Java, the interactive shell is the main shift in how you work.

Common Sticking Points

  • Assuming it is only a standalone tool. Incanter is explicitly designed to work both standalone and as embedded libraries, so pick the mode that matches your project.
  • Skipping the getting started page. The download and source routes both point there; it is the intended next step after grabbing the code.
  • Choosing the wrong build tool. The dependency instructions differ between Leiningen (project.clj) and Maven (pom.xml) — use the one your project already uses.

For examples of statistical programming with Incanter, the project's documentation is the place to continue after setup.