Book Image

Clojure Data Analysis Cookbook - Second Edition

By : Eric Richard Rochester
Book Image

Clojure Data Analysis Cookbook - Second Edition

By: Eric Richard Rochester

Overview of this book

Table of Contents (19 chapters)
Clojure Data Analysis Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Working with changes in values


Sometimes, we are more interested in how values change over time, or across some other progression, than we are in the values themselves. This information is latent in the data, but making it explicit makes it easier to work with and visualize.

Getting ready

First, we'll use these dependencies in our project.clj:

(defproject statim "0.1.0"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [incanter "1.5.5"]])

We also need to require Incanter in our script or REPL:

(require '[incanter.core :as i]
         'incanter.io)

Finally, we'll use the Virginia census data. You can download the file from http://www.ericrochester.com/clj-data-analysis/data/all_160_in_51.P3.csv:

(def data-file "data/all_160_in_51.P3.csv")

How to do it…

For this recipe, we'll take some census data and add a column to show the change in population between the 2000 and 2010 censuses:

  1. To begin, we'll need to read in the data:

    (def data
      (incanter.io/read-dataset data-file 
      :header true...