When dealing with large datasets, it's useful to be able to query the data based on some arbitrary conditions. Also, it's more reliable to store the data in a database rather than in a flat file or as an in-memory resource. The Incanter library provides us with several useful functions to perform these operations, as we will demonstrate in the code example that will follow.
Note
The Incanter library and the MongoDB driver used in the upcoming example can be added to a Leiningen project by adding the following dependency to the project.clj
file:
[congomongo "0.4.1"] [incanter "1.5.4"]
For the upcoming example, the namespace declaration should look similar to the following declaration:
(ns my-namespace (:use incanter.core [incanter.mongodb :only [insert-dataset fetch-dataset]] [somnium.congomongo :only [mongo!]] [incanter.datasets :only [get-dataset]]))
Also, this example requires MongoDB to be installed...