Database Reference
In-Depth Information
Introduction
We've seen Incanter ( http://incanter.org/ ) earlier in this topic, but we'll spend a lot more
time with this library over the next few chapters. Incanter combines the power to do statistics
using a fully-featured statistical language such as R ( http://www.r-project.org/ ) with the
ease and joy of Clojure.
Incanter's core data structure is the dataset, so we'll spend some time in this chapter to
look at how to use them effectively. While learning basic tools in this manner is often not the
most exciting way to spend your time, it can still be incredibly useful. At its most fundamental
level, an Incanter dataset is a table of rows. Each row has the same set of columns, much
like a spreadsheet. The data in each cell of an Incanter dataset can be a string or a numeric.
However, some operations require the data to only be numeric.
First you'll learn how to populate and view datasets, then you'll learn different ways
to query and project the parts of the dataset that you're interested in onto a new dataset.
Finally, we'll take a look at how to save datasets and merge multiple datasets together.
Loading Incanter's sample datasets
Incanter comes with a set of default datasets that are useful for exploring Incanter's
functions. I haven't made use of them in this topic, since there is so much data available in
other places, but they're a great way to get a feel of what you can do with Incanter. Some of
these datasets—for instance, the Iris dataset—are widely used to teach and test statistical
algorithms. It contains the species and petal and sepal dimensions for 50 irises. This is the
dataset that we'll access today.
In this recipe, we'll load a dataset and see what it contains.
Getting ready
We'll need to include Incanter in our Leiningen project.clj ile:
(defproject inc-dsets "0.1.0"
:dependencies [[org.clojure/clojure "1.6.0"]
[incanter "1.5.5"]])
We'll also need to include the right Incanter namespaces into our script or REPL:
(use '(incanter core datasets))
 
Search WWH ::




Custom Search