Book Image

Clojure Data Analysis Cookbook

By : Eric Rochester
Book Image

Clojure Data Analysis Cookbook

By: Eric Rochester

Overview of this book

<p>Data is everywhere and it's increasingly important to be able to gain insights that we can act on. Using Clojure for data analysis and collection, this book will show you how to gain fresh insights and perspectives from your data with an essential collection of practical, structured recipes.<br /><br />"The Clojure Data Analysis Cookbook" presents recipes for every stage of the data analysis process. Whether scraping data off a web page, performing data mining, or creating graphs for the web, this book has something for the task at hand.<br /><br />You'll learn how to acquire data, clean it up, and transform it into useful graphs which can then be analyzed and published to the Internet. Coverage includes advanced topics like processing data concurrently, applying powerful statistical techniques like Bayesian modelling, and even data mining algorithms such as K-means clustering, neural networks, and association rules.</p>
Table of Contents (18 chapters)
Clojure Data Analysis Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Selecting rows with $


The Incanter macro $ also pulls rows out of a dataset. In this recipe, we'll see this in action.

Getting ready

For this recipe, we'll use the same dependencies, imports, and data that we did in the Selecting columns with $ recipe.

How to do it…

Like using $ to select columns, there are several ways we can use it to select rows. Refer to the following steps:

  1. We can create a sequence of the values of one row by using $ and passing it the index of the row we want and :all for the columns.

    user=> ($ 0 :all race-data)
    (100100 160 1 "" "" "" "" "" "Abanda CDP" 192 79 "" "" 192 "" 129 "" 58 "" 0 "" 0 "" 0 "" 2 "" 3 "")
  2. We can also pull out a dataset containing multiple rows by passing more than one index into $ with a vector.

    user=> ($ [0 1 2 3 4] :all race-data)
    [:GEOID :SUMLEV :STATE :COUNTY :CBSA :CSA :NECTA :CNECTA :NAME :POP100 :HU100 :POP100.2000 :HU100.2000 :P003001 :P003001.2000 :P003002 :P003002.2000 :P003003 :P003003.2000 :P003004 :P003004.2000 :P003005 :P003005...