Selecting columns with $
Often, you need to cut the data to make it more useful. One common transformation is to pull out all the values from one or more columns into a new dataset. This can be useful for generating summary statistics or aggregating the values of some columns.
The Incanter macro $
slices out parts of a dataset. In this recipe, we'll see this in action.
Getting ready
For this recipe, we'll need to have Incanter listed in our project.clj
file:
(defproject inc-dsets "0.1.0" :dependencies [[org.clojure/clojure "1.6.0"] [incanter "1.5.5"] [org.clojure/data.csv "0.1.2"]])
We'll also need to include these libraries in our script or REPL:
(require '[clojure.java.io :as io] '[clojure.data.csv :as csv] '[clojure.string :as str] '[incanter.core :as i])
Moreover, we'll need some data. This time, we'll use some country data from the World Bank. Point your browser to http://data.worldbank.org/country and select a country. I picked...