Loading Clojure data structures into datasets
While they are good for learning, Incanter's built-in datasets probably won't be that useful for your work (unless you work with irises). Other recipes cover ways to get data from CSV files and other sources into Incanter (see Chapter 1, Importing Data for Analysis). Incanter also accepts native Clojure data structures in a number of formats. We'll take look at a couple of these in this recipe.
Getting ready
We'll just need Incanter listed in our project.clj
file:
(defproject inc-dsets "0.1.0" :dependencies [[org.clojure/clojure "1.6.0"] [incanter "1.5.5"]])
We'll also need to include this in our script or REPL:
(use 'incanter.core)
How to do it…
The primary function used to convert data into a dataset is to-dataset
. While it can convert single, scalar values into a dataset, we'll start with slightly more complicated inputs.
Generally, you'll be working with at least a matrix. If you pass this to
to-dataset
, what do you get?user=>...