100% found this document useful (5 votes)
48 views

Download Clojure Data Analysis Cookbook 1st Edition Eric Rochester ebook All Chapters PDF

Eric

Uploaded by

henyeyumii33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (5 votes)
48 views

Download Clojure Data Analysis Cookbook 1st Edition Eric Rochester ebook All Chapters PDF

Eric

Uploaded by

henyeyumii33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 61

Download Full ebookname - Read Now at ebookname.

com

Clojure Data Analysis Cookbook 1st Edition Eric


Rochester

https://ebookname.com/product/clojure-data-analysis-
cookbook-1st-edition-eric-rochester/

OR CLICK BUTTON

DOWLOAD EBOOK

Discover More Ebook - Explore Now at ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Clojure Data Analysis Cookbook 2nd Edition Eric Rochester

https://ebookname.com/product/clojure-data-analysis-cookbook-2nd-
edition-eric-rochester/

ebookname.com

Clojure Data Structures and Algorithms Cookbook 25 recipes


to deeply understand and implement advanced algorithms in
Clojure 1st Edition Rafik Naccache
https://ebookname.com/product/clojure-data-structures-and-algorithms-
cookbook-25-recipes-to-deeply-understand-and-implement-advanced-
algorithms-in-clojure-1st-edition-rafik-naccache/
ebookname.com

Haskell Data Analysis Cookbook 1st Edition Nishant Shukla

https://ebookname.com/product/haskell-data-analysis-cookbook-1st-
edition-nishant-shukla/

ebookname.com

EMQs for the MRCS Part A 1st Edition Sri G. Thrumurthy

https://ebookname.com/product/emqs-for-the-mrcs-part-a-1st-edition-
sri-g-thrumurthy/

ebookname.com
Epistemology 1st Edition Richard Fumerton

https://ebookname.com/product/epistemology-1st-edition-richard-
fumerton/

ebookname.com

Jedi Twilight Star Wars Coruscant Nights I 1st Printing


Edition Michael Reaves

https://ebookname.com/product/jedi-twilight-star-wars-coruscant-
nights-i-1st-printing-edition-michael-reaves/

ebookname.com

Effective Instructional Strategies 4th Edition Kenneth D.


Moore

https://ebookname.com/product/effective-instructional-strategies-4th-
edition-kenneth-d-moore/

ebookname.com

Measuring Society 1st Edition Chaitra H. Nagaraja

https://ebookname.com/product/measuring-society-1st-edition-chaitra-h-
nagaraja/

ebookname.com

Nanocarbons for Advanced Energy Storage 1st Edition


Xinliang Feng (Ed.)

https://ebookname.com/product/nanocarbons-for-advanced-energy-
storage-1st-edition-xinliang-feng-ed/

ebookname.com
Photographic multishot techniques high dynamic range super
resolution extended depth of field stitching 1st ed
Edition Gulbins
https://ebookname.com/product/photographic-multishot-techniques-high-
dynamic-range-super-resolution-extended-depth-of-field-stitching-1st-
ed-edition-gulbins/
ebookname.com
Clojure Data Analysis
Cookbook

Over 110 recipes to help you dive into the world of


practical data analysis using Clojure

Eric Rochester

BIRMINGHAM - MUMBAI
Clojure Data Analysis Cookbook

Copyright © 2013 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the publisher,
except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers
and distributors will be held liable for any damages caused or alleged to be caused directly or
indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies
and products mentioned in this book by the appropriate use of capitals. However, Packt
Publishing cannot guarantee the accuracy of this information.

First published: March 2013

Production Reference: 1130313

Published by Packt Publishing Ltd.


Livery Place
35 Livery Street
Birmingham B3 2PB, UK.

ISBN 978-1-78216-264-3

www.packtpub.com

Cover Image by J.Blaminsky ([email protected])


Credits

Author Project Coordinator


Eric Rochester Anugya Khurana

Reviewers Proofreaders
Jan Borgelin Mario Cecere
Thomas A. Faulhaber, Jr. Sandra Hopper
Charles M. Norton
Miki Tebeka Indexer
Monica Ajmera Mehta

Acquisition Editor
Erol Staveley Graphics
Aditi Gajjar

Lead Technical Editor


Dayan Hyames Production Coordinator
Nilesh R. Mohite

Technical Editors
Nitee Shetty Cover Work
Nilesh R. Mohite
Dennis John
About the Author

Eric Rochester enjoys reading, writing, and spending time with his wife and kids. When
he's not doing those things, he programs in a variety of languages and platforms, including
websites and systems in Python and libraries for linguistics and statistics in C#. Currently, he's
exploring functional programming languages, including Clojure and Haskell. He works at the
Scholars' Lab in the library at the University of Virginia, helping humanities professors and
graduate students realize their digitally informed research agendas.

I'd like to thank everyone. My technical reviewers—Jan Borgelin, Tom


Faulhaber, Charles Norton, and Miki Tebeka—proved invaluable. Also, thank
you to the editorial staff at Packt Publishing. This book is much stronger for
all of their feedbacks, and any remaining deficiencies are mine alone.

Thank you to Bethany Nowviskie and Wayne Graham. They've made the
Scholars' Lab a great place to work, with interesting projects, as well as
space to explore our own interests.

And especially I would like to thank Jackie and Melina. They've been
exceptionally patient and supportive while I worked on this project. Without
them, it wouldn't be worth it.
About the Reviewers

Jan Borgelin is a technology geek with over 10 years of professional software development
experience. Having worked in diverse positions in the field of enterprise software, he currently
works as a CEO and Senior Consultant for BA Group Ltd., an IT consultancy based in Finland.
For the past 2 years, he has been more actively involved in functional programming and as
part of that has become interested in Clojure among other things.

I would like to thank my family and our employees for tolerating my


excitement about the book throughout the review process.

Thomas A. Faulhaber, Jr., is principal of Infolace (www.infolace.com), a San


Francisco-based consultancy. Infolace helps clients from startups to global brands turn raw
data into information and information into action. Throughout his career, he has developed
systems for high-performance TCP/IP, large-scale scientific visualization, energy trading, and
many more.

He has been a contributor to, and user of, Clojure and Incanter since their earliest days. The
power of Clojure and its ecosystem (of both code and people) is an important "magic bullet" in
Tom's practice.
Charles Norton has over 25 years of programming experience, ranging from factory
automation applications and firmware to network middleware, and is currently a programmer
and application specialist for a Greater Boston municipality. He maintains and develops a
collection of software applications that support finances, health insurance, and water utility
administration. These systems are implemented in several languages, including Clojure.

Miki Tebeka has been shipping software for more than 10 years. He has developed a
wide variety of products from assemblers and linkers to news trading systems to cloud
infrastructures. He currently works at Adconion where he shuffles through more than 6 billion
monthly events. In his free time, he is active in several open source communities.
www.PacktPub.com

Support files, eBooks, discount offers and more


You might want to visit www.PacktPub.com for support files and downloads related to
your book.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub
files available? You can upgrade to the eBook version at www.PacktPub.com and as a print
book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
[email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up
for a range of free newsletters and receive exclusive discounts and offers on Packt books
and eBooks.
TM

http://PacktLib.PacktPub.com

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book
library. Here, you can access, read and search across Packt's entire library of books.

Why Subscribe?
ff Fully searchable across every book published by Packt
ff Copy and paste, print and bookmark content
ff On demand and accessible via web browser

Free Access for Packt account holders


If you have an account with Packt at www.PacktPub.com, you can use this to access
PacktLib today and view nine entirely free books. Simply use your login credentials for
immediate access.
Table of Contents
Preface 1
Chapter 1: Importing Data for Analysis 7
Introduction 7
Creating a new project 8
Reading CSV data into Incanter datasets 9
Reading JSON data into Incanter datasets 11
Reading data from Excel with Incanter 12
Reading data from JDBC databases 13
Reading XML data into Incanter datasets 16
Scraping data from tables in web pages 19
Scraping textual data from web pages 23
Reading RDF data 26
Reading RDF data with SPARQL 29
Aggregating data from different formats 34
Chapter 2: Cleaning and Validating Data 41
Introduction 41
Cleaning data with regular expressions 42
Maintaining consistency with synonym maps 44
Identifying and removing duplicate data 45
Normalizing numbers 48
Rescaling values 50
Normalizing dates and times 51
Lazily processing very large data sets 54
Sampling from very large data sets 56
Fixing spelling errors 57
Parsing custom data formats 61
Validating data with Valip 64
Table of Contents

Chapter 3: Managing Complexity with Concurrent Programming 67


Introduction 68
Managing program complexity with STM 69
Managing program complexity with agents 73
Getting better performance with commute 75
Combining agents and STM 77
Maintaining consistency with ensure 79
Introducing safe side effects into the STM 82
Maintaining data consistency with validators 84
Tracking processing with watchers 87
Debugging concurrent programs with watchers 90
Recovering from errors in agents 91
Managing input with sized queues 93
Chapter 4: Improving Performance with Parallel Programming 95
Introduction 95
Parallelizing processing with pmap 96
Parallelizing processing with Incanter 100
Partitioning Monte Carlo simulations for better pmap performance 102
Finding the optimal partition size with simulated annealing 106
Parallelizing with reducers 110
Generating online summary statistics with reducers 114
Harnessing your GPU with OpenCL and Calx 116
Using type hints 120
Benchmarking with Criterium 123
Chapter 5: Distributed Data Processing with Cascalog 127
Introduction 128
Distributed processing with Cascalog and Hadoop 129
Querying data with Cascalog 132
Distributing data with Apache HDFS 134
Parsing CSV files with Cascalog 137
Complex queries with Cascalog 139
Aggregating data with Cascalog 142
Defining new Cascalog operators 143
Composing Cascalog queries 146
Handling errors in Cascalog workflows 149
Transforming data with Cascalog 151
Executing Cascalog queries in the Cloud with Pallet 152
Chapter 6: Working with Incanter Datasets 159
Introduction 159
Loading Incanter's sample datasets 160
ii
Table of Contents
Loading Clojure data structures into datasets 161
Viewing datasets interactively with view 163
Converting datasets to matrices 164
Using infix formulas in Incanter 166
Selecting columns with $ 168
Selecting rows with $ 170
Filtering datasets with $where 171
Grouping data with $group-by 174
Saving datasets to CSV and JSON 175
Projecting from multiple datasets with $join 177
Chapter 7: Preparing for and Performing Statistical Data Analysis
with Incanter 181
Introduction 182
Generating summary statistics with $rollup 182
Differencing variables to show changes 185
Scaling variables to simplify variable relationships 186
Working with time series data with
Incanter Zoo 189
Smoothing variables to decrease noise 192
Validating sample statistics with bootstrapping 194
Modeling linear relationships 197
Modeling non-linear relationships 200
Modeling multimodal Bayesian distributions 204
Finding data errors with Benford's law 207
Chapter 8: Working with Mathematica and R 211
Introduction 212
Setting up Mathematica to talk to Clojuratica for Mac OS X and Linux 212
Setting up Mathematica to talk to Clojuratica for Windows 216
Calling Mathematica functions from Clojuratica 218
Sending matrices to Mathematica from Clojuratica 219
Evaluating Mathematica scripts from Clojuratica 220
Creating functions from Mathematica 221
Processing functions in parallel in Mathematica 222
Setting up R to talk to Clojure 224
Calling R functions from Clojure 226
Passing vectors into R 227
Evaluating R files from Clojure 228
Plotting in R from Clojure 230

iii
Table of Contents

Chapter 9: Clustering, Classifying, and Working with Weka 233


Introduction 233
Loading CSV and ARFF files into Weka 234
Filtering and renaming columns in Weka datasets 236
Discovering groups of data using K-means clustering 239
Finding hierarchical clusters in Weka 245
Clustering with SOMs in Incanter 248
Classifying data with decision trees 250
Classifying data with the Naive Bayesian classifier 253
Classifying data with support vector machines 255
Finding associations in data with the Apriori algorithm 258
Chapter 10: Graphing in Incanter 261
Introduction 261
Creating scatter plots with Incanter 262
Creating bar charts with Incanter 264
Graphing non-numeric data in bar charts 266
Creating histograms with Incanter 268
Creating function plots with Incanter 270
Adding equations to Incanter charts 272
Adding lines to scatter charts 273
Customizing charts with JFreeChart 276
Saving Incanter graphs to PNG 278
Using PCA to graph multi-dimensional data 279
Creating dynamic charts with Incanter 282
Chapter 11: Creating Charts for the Web 285
Introduction 285
Serving data with Ring and Compojure 286
Creating HTML with Hiccup 290
Setting up to use ClojureScript 293
Creating scatter plots with NVD3 296
Creating bar charts with NVD3 302
Creating histograms with NVD3 305
Visualizing graphs with force-directed layouts 308
Creating interactive visualizations with D3 313
Index 317

iv
Preface
Data's everywhere! And, as it has become more pervasive, our desire to use it has grown
just as quickly. A lot hides in data: potential sales, users' browsing patterns, demographic
information, and many, many more things. There are insights we could gain and decisions we
could make better, if only we could find out what's in our data.

This book will help with that.

The programming language Clojure will help us. Clojure was first released in 2007 by Rich
Hickey. It's a member of the lisp family of languages, and it has the strengths and flexibility
that they provide. It's also functional, so Clojure programs are easy to reason with. And, it
has amazing features for working concurrently and in parallel. All of these can help us as we
analyze data while keeping things simple and fast.

Clojure's usefulness for data analysis is further improved by a number of strong libraries.
Incanter provides a practical environment for working with data and performing statistical
analysis. Cascalog is an easy-to-use wrapper over Hadoop and Cascading. Finally, when
we're ready to publish our results, ClojureScript, an implementation of Clojure that generates
JavaScript, can help us to visualize our data in an effective and persuasive way.

Moreover, Clojure runs on the Java Virtual Machine (JVM), so any libraries written for Java are
available too. This gives Clojure an incredible amount of breadth and power.

I hope that this book will give you the tools and techniques you need to get answers from
your data.
Preface

What this book covers


Chapter 1, Importing Data for Analysis, will cover how to read data from a variety of sources,
including CSV files, web pages, and linked semantic web data.

Chapter 2, Cleaning and Validating Data, will present strategies and implementations for
normalizing dates, fixing spelling, and working with large datasets. Getting data into a useable
shape is an important, but often overlooked, stage of data analysis.

Chapter 3, Managing Complexity with Concurrent Programming, will cover Clojure's


concurrency features and how we can use them to simplify our programs.

Chapter 4, Improving Performance with Parallel Programming, will cover using Clojure's
parallel processing capabilities to speed up processing data.

Chapter 5, Distributed Data Processing with Cascalog, will cover using Cascalog as a wrapper
over Hadoop and the Cascading library to process large amounts of data distributed over
multiple computers. The final recipe in this chapter will use Pallet to run a simple analysis on
Amazon's EC2 service.

Chapter 6, Working with Incanter Datasets, will cover the basics of working with Incanter
datasets. Datasets are the core data structure used by Incanter, and understanding them is
necessary to use Incanter effectively.

Chapter 7, Preparing for and Performing Statistical Data Analysis with Incanter, will cover
a variety of statistical processes and tests used in data analysis. Some of these are quite
simple, such as generating summary statistics. Others are more complex, such as performing
linear regressions and auditing data with Benford's Law.

Chapter 8, Working with Mathematica and R, will talk about setting up Clojure to talk to
Mathematica or R. These are powerful data analysis systems, and sometimes we might want
to use them. This chapter will show us how to get these systems to work together, as well as
some tasks we can do once they are communicating.

Chapter 9, Clustering, Classifying, and Working with Weka, will cover more advanced machine
learning techniques. In this chapter, we'll primarily use the Weka machine learning library, and
some recipes will discuss how to use it and the data structures its built on, while other recipes
will demonstrate machine learning algorithms.

Chapter 10, Graphing in Incanter, will show how to generate graphs and other visualizations
in Incanter. These can be important for exploring and learning about your data and also for
publishing and presenting your results.

Chapter 11, Creating Charts for the Web, will show how to set up a simple web application
to present findings from data analysis. It will include a number of recipes that leverage the
powerful D3 visualization library.

2
Preface

What you need for this book


One piece of software required for this book is the Java Development Kit (JDK), which you can
get from http://www.oracle.com/technetwork/java/javase/downloads/index.
html. The JDK is necessary to run and develop on the Java platform.

The other major piece of software that you'll need is Leiningen 2, which you can download
and install from https://github.com/technomancy/leiningen. Leiningen 2 is a tool
for managing Clojure projects and their dependencies. It's quickly becoming the de facto
standard project tool in the Clojure community.

Throughout this book, we'll use a number of other Clojure and Java libraries, including Clojure
itself. Leiningen will take care of downloading these for us as we need them.

You'll also need a text editor or integrated development environment (IDE). If you already
have a text editor that you like, you can probably use it. See http://dev.clojure.org/
display/doc/Getting+Started for tips and plugins for using your particular favorite
environment. If you don't have a preference, I'd suggest looking at using Eclipse with
Counterclockwise. There are instructions for getting this set up at http://dev.clojure.
org/display/doc/Getting+Started+with+Eclipse+and+Counterclockwise.

That is all that's required. However, at various places throughout the book, some recipes will
access other software. The recipes in Chapter 8, Working with Mathematica and R, that relate
to Mathematica will require Mathematica, obviously, and those that relate to R, will require
that. However, these programs won't be used in the rest of the book, and whether you're
interested in these recipes might depend on whether you already have this software available.

Who this book is for


This book is for programmers or data scientists who are familiar with Clojure and want to use
it in their data analysis processes. This isn't a tutorial on Clojure—there are already a number
of excellent introductory books out there—so you'll need to be familiar with the language;
however, you don't need to be an expert at it.

Likewise, you don't need to be an expert on data analysis, although you should probably be
familiar with its tasks, processes, and techniques. While you might be able to glean enough
from these recipes to get started, to be truly effective, you'll want to get a more thorough
introduction to this field.

Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of
information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: " We just need to make sure that the clojure.
string/upper-case function is available."

3
Preface

A block of code is set as follows:


(defn fuzzy=
"This returns a fuzzy match."
[a b]
(let [dist (fuzzy-dist a b)]
(or (<= dist fuzzy-max-diff)
(<= (/ dist (min (count a) (count b)))
fuzzy-percent-diff))))

When we wish to draw your attention to a particular part of a code block, the relevant lines or
items are set in bold:
[ring.middleware.file-info :only (wrap-file-info)]
[ring.middleware.stacktrace :only (wrap-stacktrace)]
[ring.util.response :only (redirect)]
[hiccup core element page]
[hiccup.middleware :only (wrap-base-url)]))

Any command-line input or output is written as follows:


$ lein cljsbuild auto
Compiling ClojureScript.
Compiling "resources/js/scripts.js" from "src-cljs"...
Successfully compiled "resources/js/script.js" in 4.707129 seconds.

New terms and important words are shown in bold. Words that you see on the screen, in
menus or dialog boxes for example, appear in the text like this: "errors are found in the page
Agents and Asynchronous Actions in the Clojure documentation ".

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this
book—what you liked or may have disliked. Reader feedback is important for us to develop
titles that you really get the most out of.

4
Preface

To send us general feedback, simply send an e-mail to [email protected], and


mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or
contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to
get the most from your purchase.

Downloading the example code


You can download the example code files for all Packt books you have purchased from your
account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit
http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do
happen. If you find a mistake in one of our books—maybe a mistake in the text or the
code—we would be grateful if you would report this to us. By doing so, you can save other
readers from frustration and help us improve subsequent versions of this book. If you find
any errata, please report them by visiting http://www.packtpub.com/submit-errata,
selecting your book, clicking on the errata submission form link, and entering the details of
your errata. Once your errata are verified, your submission will be accepted and the errata
will be uploaded on our website, or added to any list of existing errata, under the Errata
section of that title. Any existing errata can be viewed by selecting your title from
http://www.packtpub.com/support.

Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt,
we take the protection of our copyright and licenses very seriously. If you come across any
illegal copies of our works, in any form, on the Internet, please provide us with the location
address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions
You can contact us at [email protected] if you are having a problem with any
aspect of the book, and we will do our best to address it.

5
Importing Data for
1
Analysis
In this chapter, we will cover:

ff Creating a new project


ff Reading CSV data into Incanter datasets
ff Reading JSON data into Incanter datasets
ff Reading data from Excel with Incanter
ff Reading data from JDBC databases
ff Reading XML data into Incanter datasets
ff Scraping data from tables in web pages
ff Scraping textual data from web pages
ff Reading RDF data
ff Reading RDF data with SPARQL
ff Aggregating data from different formats

Introduction
There's not a lot of data analysis that we can do without data, so the first step in any project is
evaluating what data we have and what we need. And once we have some idea of what we'll
need, we have to figure out how to get it.
Importing Data for Analysis

Many of the recipes in this chapter and in this book use Incanter (http://incanter.org/)
to import the data and target Incanter datasets. Incanter is a library for doing statistical
analysis and graphics in Clojure, similar to R. Incanter may not be suitable for every task—later
we'll use the Weka library for clustering and machine learning—but it is still an important part
of our toolkit for doing data analysis in Clojure. This chapter has a collection of recipes for
gathering data and making it accessible to Clojure. For the very first recipe, we'll look at how
to start a new project. We'll start with very simple formats like comma-separated values (CSV)
and move into reading data from relational databases using JDBC. Then we'll examine more
complicated data sources, such as web scraping and linked data (RDF).

Creating a new project


Over the course of this book, we're going to use a number of third-party libraries and external
dependencies. We need a tool to download them and track them. We also need a tool to set
up the environment and start a read-eval-print-loop (REPL, or interactive interpreter), which
can access our code, or to execute our program.

We'll use Leiningen for that (http://leiningen.org/). This has become a standard
package automation and management system.

Getting ready
Visit the Leiningen site (http://leiningen.org/) and download the lein script. This will
download the Leiningen JAR file. The instructions are clear, and it's a simple process.

How to do it...
To generate a new project, use the lein new command, passing it the name of the project:
$ lein new getting-data
Generating a project called getting-data based on the 'default' template.
To see other templates (app, lein plugin, etc), try 'lein help new'.

Now, there will be a new subdirectory named getting-data. It will contain files with stubs
for the getting-data.core namespace and for tests.

Downloading the example code


You can download the example code files for all Packt books you have
purchased from your account at http://www.packtpub.com. If you
purchased this book elsewhere, you can visit http://www.packtpub.
com/support and register to have the files e-mailed directly to you.

8
Chapter 1

How it works...
The new project directory also contains a file named project.clj. This file contains
metadata about the project: its name, version, and license. It also contains a list of
dependencies that our code will use. The specifications it uses allows it to search Maven
repositories and directories of Clojure libraries (Clojars, https://clojars.org/) to
download the project's dependencies.
(defproject getting-data "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.4.0"]])

In the Getting ready section of each recipe, we'll see what libraries we need to list in the
:dependencies section of this file.

Reading CSV data into Incanter datasets


One of the simplest data formats is comma-separated values (CSV). And it's everywhere. Excel
reads and writes CSV directly, as do most databases. And because it's really just plain text, it's
easy to generate or access it using any programming language.

Getting ready
First, let's make sure we have the correct libraries loaded. The project file of Leiningen
(https://github.com/technomancy/leiningen), the project.clj file, should
contain these dependencies (although you may be able to use more up-to-date versions):
:dependencies [[org.clojure/clojure "1.4.0"]
[incanter/incanter-core "1.4.1"]
[incanter/incanter-io "1.4.1"]]

Also, in your REPL or in your file, include these lines:


(use 'incanter.core
'incanter.io)

Finally, I have a file named data/small-sample.csv that contains the following data:
Gomez,Addams,father
Morticia,Addams,mother
Pugsley,Addams,brother
Wednesday,Addams,sister

9
Importing Data for Analysis

You can download this file from http://www.ericrochester.com/clj-data-


analysis/data/small-sample.csv. There's a version with a header row at http://
www.ericrochester.com/clj-data-analysis/data/small-sample-header.csv.

How to do it…
1. Use the incanter.io/read-dataset function:
user=> (read-dataset "data/small-sample.csv")
[:col0 :col1 :col2]
["Gomez" "Addams" "father"]
["Morticia" "Addams" "mother"]
["Pugsley" "Addams" "brother"]
["Wednesday" "Addams" "sister"]

2. If we have a header row in the CSV file, then we include :header true in the call to
read-dataset:

user=> (read-dataset "data/small-sample-header.csv" :header true)


[:given-name :surname :relation]
["Gomez" "Addams" "father"]
["Morticia" "Addams" "mother"]
["Pugsley" "Addams" "brother"]

How it works…
Using Clojure and Incanter makes a lot of common tasks easy. This is a good example of that.

We've taken some external data, in this case from a CSV file, and loaded it into an Incanter
dataset. In Incanter, a dataset is a table, similar to a sheet in a spreadsheet or a database
table. Each column has one field of data, and each row has an observation of data. Some
columns will contain string data (all of the columns in this example did), some will contain
dates, some numeric data. Incanter tries to detect automatically when a column contains
numeric data and coverts it to a Java int or double. Incanter takes away a lot of the pain
of importing data.

There's more…
If we don't want to involve Incanter—when you don't want the added dependency, for
instance—data.csv is also simple (https://github.com/clojure/data.csv).
We'll use this library in later chapters, for example, in the recipe Lazily processing very
large datasets of Chapter 2, Cleaning and Validating Data.

10
Chapter 1

See also
ff Chapter 6, Working with Incanter Datasets

Reading JSON data into Incanter datasets


Another data format that's becoming increasingly popular is JavaScript Object Notation
(JSON, http://json.org/). Like CSV, this is a plain-text format, so it's easy for programs
to work with. It provides more information about the data than CSV does, but at the cost of
being more verbose. It also allows the data to be structured in more complicated ways, such
as hierarchies or sequences of hierarchies.

Because JSON is a much fuller data model than CSV, we may need to transform the data.
In that case, we can pull out just the information we're interested in and flatten the nested
maps before we pass it to Incanter. In this recipe, however, we'll just work with fairly simple
data structures.

Getting ready
First, include these dependencies in the Leiningen project.clj file:
:dependencies [[org.clojure/clojure "1.4.0"]
[incanter/incanter-core "1.4.1"]
[org.clojure/data.json "0.2.1"]]

Use these libraries in our REPL interpreter or in our program:


(use 'incanter.core
'clojure.data.json)

And have some data. For this, I have a file named data/small-sample.json that looks
like the following:
[{"given_name": "Gomez",
"surname": "Addams",
"relation": "father"},
{"given_name": "Morticia",
"surname": "Addams",
"relation": "mother"}, …
]

You can download this data file from http://www.ericrochester.com/clj-data-


analysis/data/small-sample.json.

11
Importing Data for Analysis

How to do it…
Once everything's in place, this is just a one-liner, which we can execute at the REPL
interpreter:
user=> (to-dataset (read-json (slurp "data/small-sample.json")))
[:given_name :surname :relation]
["Gomez" "Addams" "father"]
["Morticia" "Addams" "mother"]
["Pugsley" "Addams" "brother"]

How it works…
Like all Lisps, Clojure is usually read from inside out, from right to left. Let's break it down.
clojure.core/slurp reads in the contents of the file and returns it as a string. This is
obviously a bad idea for very large files, but for small ones it's handy. clojure.data.json/
read-json takes the data from slurp, parses it as JSON, and returns native Clojure data
structures. In this case, it returns a vector of maps. maps.incanter.core/to-dataset
takes a sequence of maps and returns an Incanter dataset. This will use the keys in the maps as
column names and will convert the data values into a matrix. Actually, to-dataset can accept
many different data structures. Try (doc to-dataset) in the REPL interpreter or see the
Incanter documentation at http://data-sorcery.org/contents/ for more information.

Reading data from Excel with Incanter


We've seen how Incanter makes a lot of common data-processing tasks very simple; reading
an Excel spreadsheet is another example of this.

Getting ready
First, make sure that our Leiningen project.clj file contains the right dependencies:
:dependencies [[org.clojure/clojure "1.4.0"]
[incanter/incanter-core "1.4.1"]
[incanter/incanter-excel "1.4.1"]]

Also, make sure that we've loaded those packages into the REPL interpreter or script:
(use 'incanter.core
'incanter.excel)

12
Random documents with unrelated
content Scribd suggests to you:
STARVING AMERICA
By Alfred W. McCann. F. M. Barton. 270 pp. Price $1.50; by
mail of The Survey $1.61.
This is an adulterating age. The organized exploitation of the
primary wants of civilized mankind, the demand for products
prepared for immediate consumption, the stimulation of new desires
by unprecedented advertising campaigns, the conspicuous
consumption of the rich and the unreasoning imitation of the richer
by the poorer, the ever lengthening cycle of production from raw
material to finished product, the fierce competition among
manufacturers and dispensers of goods, the rising cost of living, and
more than all, the amazing carelessness of the purchasing public,
especially with regard to articles of food and clothing, have caused
the adulterators to multiply and flourish and have developed
adulteration to a fine art.
The exposure of various forms of food impurities and adulterants,
harmless or criminal, is neither new nor unpublished. Few men in
our country are better known than Harvey Wiley, and Wiley in the
popular mind stands as the champion of pure food and the
implacable foe of fraudulent food distributors. No person who reads
or listens but knows something of Wiley and something of impure
food supplies.
Mr. McCann, whose book under the sensational title of Starving
America has recently appeared, is no less valiant than Wiley in his
promulgation of pure-food propaganda. Almost unknown,
unsupported by the scientific training and the official standing which
Wiley possesses, this dark champion girds on his armor and
heroically enters the lists, shouting, “I’ll tell the truth if I die for it.”
Of course there’s no danger of his dying for it. Speaking logically, the
conclusion seems to be that the rest of us will die of starvation if we
refuse to heed his speaking.
In general the book supports two theses:
First, that the mineral constituents of foods are much more
important in body building than food chemists and dietitians are
aware; in fact, that we are either literally starving ourselves and our
children by eliminating the ash from our bread, meat, potatoes, rice
and other foods, or we are rendering our bodies susceptible to
disease—such as tuberculosis—through failure to supply certain
mineral defenses to the tissues. The essential ashes, always present
in food stuffs—vegetable or animal—in their original raw state, are
removed in the manufacture or in the cooking. Wholesome
nutritious whole wheat bread and unpolished rice are set over
against the insidious, emasculated, mineral-denuded white bread
and polished rice—real whited sepulchers, beautiful but deadly.
In the development of this thesis Mr. McCann presents some facts
already published and fully accepted, and an array of startling
statements. Most of his reasoning is, of course, deductive, because
scientists have little authentic data to offer on the effect of the
various mineral elements or the lack of them, much less on the most
desirable methods of introducing them into the human system.
Though neither a university man, nor a graduate chemist, it appears
that the author has had exceptional opportunities to study
biochemistry as an amateur; and formerly, as advertising agent of a
large food industry he spent much time in the food laboratory of the
concern. Notwithstanding these qualifications, which he fully sets
forth in his preface, some of his conclusions, for example the vital
importance of ash in the system and the dire results of our ordinary
dietary, though analogically sound, fail to convince the student and
perhaps the layman.
On his second proposition, that an astonishing variety and an
appalling quantity of our foods are poisonously adulterated both
legally and criminally, the author stands on sure ground. Candies,
ice-cream, extracts, patent medicines, preservatives, coloring
materials are handled without reserve. The argument is supported
almost wholly by old material, rather familiar to the magazine
reading public; but the cumulative evidence, followed by a
dissertation on the appalling and preventable infant death rate gives
strength and conviction to the presentation.
The author is not merely destructive. He urges a campaign of
education through the public press and pleads for courses and
demonstrations of pure food stuffs and their effects in our schools
and colleges. He has formulated a practical dietary, a daily menu for
a week, of simple, wholesome food, based on the principles he has
worked out, for children three years of age and over. His own
children have thrived wonderfully on it. He describes in one of the
most satisfactory chapters in the book an ideal restaurant that
appeals both to one’s common sense and to his appetite.
On the whole the book is timely and deserves a wide reading. In
the endeavor to catch the public ear by the presentation of a lurid
array of facts under a sensational title I fear the author has overshot
the mark. Thoughtful readers are likely to discount much that
apparently has a reasonable basis of scientific study merely because
of the overstraining after startling statement. The author’s style is
not altogether pleasing, nor does it always carry conviction nor
inspire confidence in the author. It is not a great book nor an epoch-
making one, but it bears the stamp of sincerity, provided one reads to
the end, and calls attention to a number of awful truths that should
give us pause. The keynote of progress is “light and enlightenment,”
rather than repression.
Alexander E. Cance.
THE THREE GIFTS OF LIFE
By Nellie M. Smith. Dodd, Mead & Co. 138 pp. Price $.50; by
mail of The Survey $.56
The market is flooded with publications on education with
reference to sex, and most of them are the product of superficial or
one-sided knowledge and a ready pen. The emphasis is unduly put
on disease because most writers are so impressed by the results of
ignorance that they find it impossible to take the attitude of the
normal, healthy individual whom they are trying to reach.
Among this mass of material, there have been two or three books
which could be put into the hands of young girls, but even these
should be used with care. The large demand for a good book and our
failure to meet it has been a source of anxiety to all who have
appreciated the dire need which it voiced. Then came The Three Gifts
of Life, which answers the appeal for knowledge concerning the
mysteries of reproduction, showing the origin of life in plants,
animals and human beings—not detached as physiological fact but
interwoven in ordinary experience.
The Three Gifts are the three attributes by which the different
forms of life progress: i.e., dependence, as illustrated by plants;
instinct, plus dependence, as shown by animals; choice, plus
dependence and instinct, which are given to every human being.
Throughout the interesting account of plant and animal
reproduction, Miss Smith is working through the law of progress to
the girls’ responsibility in the life of the race, showing how the
reproductive instinct can be made into a race instinct by means of
the gift of choice. The one adverse criticism I should make is calling
any gift of the flowers “poor” even in comparison. When the marvels
of plant and animal life are being so wonderfully revealed, there is a
singular opportunity to communicate the thrill and zest which come
from close contact with Nature: there is nothing poor in the “scheme
of things.”
The book does not warn girls against men’s companionship; it
does not describe the horrors of venereal diseases; it does not
frighten them into a fear of all mankind by giving the details of
prostitution. It does not prophesy changes which take place during
the adolescent period, so that attention will be concentrated on a
whole new set of feelings which may or may not appear. On the
contrary, it is all positive and sane, and is by far the best book we
have for educational work with girls.
Marion E. Dodd.
EVE’S OTHER CHILDREN
By Lucille Baldwin van Slyke. Fred’k A. Stokes. 275 pp. Price
$1.00; by mail of The Survey $1.10.
Mrs. Van Slyke has chosen as her special field of interest the
Syrian quarter of Brooklyn, and the result of her observations she
has given us in a short dozen of stories, grouped under the title, Eve’s
Other Children. With considerable skill and great charm, through the
medium of little Nazileh, she permits us to see into the mind of the
Oriental “within our gates.” Each tale illustrates some Syrian custom
or legend or characteristic, picturesquely trying to maintain itself in
this matter-of-fact “land of Brooklyn.”
Those looking for diversion will find it in these tales; those looking
for something deeper will find that also. While the association of the
Oriental with other immigrants is rather casually treated, the
relation between the Syrian population and the Americans with
whom they come in contact has been a matter of careful observation
and thought on the part of the writer. Between the lines, one feels her
protest against the current attitude toward this peculiarly sensitive
alien. Teacher and social worker, as well as the Tommy O’Brien’s and
Geraldine Schmidt’s of the neighborhood, constantly offend the little
Syrians by referring to them as “dagos.” Throughout these stories,
like a plaintive refrain, runs the explanation of little Nazileh: “Oxcuse
—me, I ees not a dago—I Syreean!”
To deal rightly with these children it is not enough to study only
the outward type. Not to blunder one must know the unique
workings of their minds, their superstitions, their strong racial traits.
To illustrate:
Baby Antar has a new tooth, to Nazileh a most important event. A
certain native dish must be prepared to do the occasion justice. But
she is so poor and her mother works so hard! Suddenly Nazileh
remembers that “Teacher” has admired her Mashallah beads; she
will give fifty cents for them. Without them, the child is defenseless
before the “evil eye,” but a Syrian custom is at stake; she must not
falter. The teacher buys them gaily, without suspicion that she has
taken from the frightened child her most valued and valuable
possession.
Nor is the philanthropist always understanding:
Nazileh’s most striking trait is her passionate love for her baby
brother. Two ladies stop her ramshackle perambulator in the street.
Antar has prickly heat. The ladies discuss ways and means; they talk
of “district tickets” and “transfer stubs.” Then the awful word
“Freshairfund” escapes them, and in a second two flying legs and
four wobbly wheels are all that are seen of Nazileh and her precious
burden. “That Freshairfun,” she gasps from a safe distance, “eet steal
sweet little babees from their homes. I weesh”—she stopped in
delight at the American oath she was about to utter—“I weesh a gosh
on eet!”
It is a great pity to deal clumsily with the Oriental, for no one can
lay down this book without feeling that there are exquisite qualities
lurking in the Syrian quarter, qualities that we as a people need.
Nazileh, gay, sad, loving, poetic, mischievous little girl, always
courteous, never shrewd, seems to represent the best type of Syrian
child. We need her filial devotion, her deference to old age, her fine
hold on tradition in this rough and ready civilization of ours.
Evidently the high tide of immigration that washes in so many
problems, brings treasure also. How can we capture it?
With much that is beautiful and picturesque, the book leaves on
our minds also the impression of great hardship, of overwork and
underpay, of little children driven indoors out of the sunlight to ply a
wearisome trade; of young girls fighting for existence in the misery of
the sweat-shop.
But the author’s sympathetic understanding and charming
interpretation of Oriental ideas, scenes, and customs mitigate the
somberness even of the final tale, which gives the title to the book.
The story is told by Nazileh’s sad young mother arrayed in bright
Oriental garb for the Syrian Christmas, when the camel comes with
gifts,—“And when Eve saw God coming, she hid all her unsightly
children in a dark cave and only her pretty children were washed and
dressed for God to see....” The lame, the halt, the blind, and those
pursued of poverty,—these are “Eve’s Other Children.”
Mary Bannister Willard.
COMMUNICATIONS
TREAT BOTH ALIKE
To the Editor:

In most phases of life it is the little things that count. In the matter
of prostitution we have heard so much about the big things—the
inevitableness of it, because the man wants it, because the girl may
have more money than her pay-envelope brings her, and the
necessity for changing public opinion before any change in dealing
with the situation can become effective—that we have become well-
nigh overwhelmed by the magnitude of the evil. Yet, may we not
expect shortly to gain public approval for two small and difficult yet
perfectly feasible changes of method in handling the situation? These
are my two suggestions:

1. When a house is raided, take all found in the house, women and men and put
their names on the police-blotter.
2. Then, examine these people for venereal disease. Restrain the liberty of all the
diseased, both women and men, till they are cured.

I am one of those heretics who are not particularly concerned with


the exact law covering the matter at the present time in any
particular place; it suffices me to know that not everywhere are these
two regulations in force; nor does declaring unconstitutional the
ordinances dealing with these things bother me. I am tremendously
interested in seeing that these ideas get across.
When the public has made these two suggestions part of its
conviction of the right way of doing things, then we will find the way
to formulate workable, constitutional regulations embodying these
suggestions.
“They” tell us that it is an infringement of the liberty of the
individual when the women taken for soliciting or in houses are
examined for disease. Most certainly it is. And practically all the
other laws on our books curtail the liberty of the individual.
But, it is an infringement of the right of the community when men
and woman with venereal disease go about freely. The community is
interested in its own perpetuation. Therefore, it is interested that the
prospective and the actual husband shall be just as clean from
disease as the girl.
But, “they” say such handling of the situation does not meet the
economic objection; these suggestions do not even attempt to
provide more cash for the girl. Good, the suggestions do not solve the
problem for her; that is just the point. She must solve it for herself.
That is the only salvation worth having. Yet, not simply by herself
and for herself. She will probably fail, if she attempts it alone. But,
joining forces with other girls and working together, success will
probably follow and there will probably be a greater amount of cash
in the pay-envelope. That is worth most to the individual which is
conquered into the person, not received as gift.
Putting these suggestions into practice will diminish greatly the
number who “have to have it.” It will make sinning less popular.
Morgan T. Riley.

New York.
INDUSTRIAL EDUCATION
To the Editor:

In your issue of March 22 there is a reference and quotation from


the statement of “Principles and Policies that Should Underlie State
Legislation for a State System of Vocational Education,” adopted at
the December meeting of the National Society for the Promotion of
Industrial Education in Philadelphia, that tends to give a wrong
impression of the attitude of the society regarding the matter of dual
control referred to in Professor Dewey’s very clear and forcible article
in the same issue.[4]
It may be stated without reservation that the executive committee
of the society are unanimously of the belief that the best way to
administer the new provisions for industrial education rapidly being
enacted into laws in various states is by a state board of education
which has all forms of education under its control.
The committee that developed the statement, however, recognized
that in some states where no board of education exists and state
control is represented by a superintendent of instruction, it is
possible that the initial development of this new work may be best
secured for a short period by a separate board of control. This point
of view is embodied in a paragraph relating to state control in the
statement of “principles and policies,” as follows:
“Effective administrative control, on the part of the state, of both
vocational and general education, requires the existence of a State
Board possessing sufficient powers, effectively to supervise all
forms of education receiving financial aid from the state. Should
such a board not exist, in any state, or should it be found that an
existing board is unprepared to deal effectively with the
establishment and promotion of vocational education, then it is
expedient that a special administrative Board of Control for
Vocational Education shall be established until such time as a state
board properly qualified to deal with all forms of state-aided
education shall exist.”
The feeling of the representative committee which formulated the
statement of “principles and policies” and which gave it careful
consideration and discussion at the meeting at Philadelphia, was that
such a separation of control while not desirable as a permanent
arrangement, might under some circumstances be of value in
effectively launching the new movement, might better secure a fair
trial of new methods, and better arouse public opinion to its
consideration.
The paragraphs quoted in The Survey do not relate to the matter
of state control, which is the point under discussion in Professor
Dewey’s paper, but to the question of separateness of instruction
being accorded vocational schools and classes. By separate
organization in this connection is meant a separate school
organization. Separation to this extent, it is safe to say, a great
majority of teachers and other educators who have been intimately
connected with real work in industrial education (not merely with
manual training as an element in the general course of study),
thoroughly believe in as essential to effective results in this field.
Such separateness of organization as is specified in the quoted
paragraphs, is typified by the organization of the Manhattan Trade
Schools for Girls, by the New York Vocational School for Boys, and
by the various other vocational schools at Rochester, Albany and
Buffalo in this state, all of which are administered by regular local
school boards.
C. R. Richards.

[Director Cooper Union.]


New York.
TODAY IT IS SPRING
To the Editor:

Today it is Spring and in office and in schools, we find ourselves


forgetting our work and leaning back to breathe the soft, warm air.
Why is it that the Spring fever fills every one’s veins, and we find
ourselves caring so little about the important interests upon which
our minds were fixed. Why do we turn to dreaming of fields and blue
distances and mornings when we discovered that some one was in
love with us. On such days as these, for a few moments, the school-
teacher must stop schooling, the trader must stop trading, the
reformer must stop reforming. What is the meaning of this? It is
God’s holiday.
In these moments we learn one of the great lessons of life. After all,
it is the cosmic forces that make the world. We learn the great lesson
of trust. Little do our efforts accomplish to brighten and beautify the
world. But when the Spring comes, even in Mulberry street the
children sing and shout, and soft gray buds are ready to burst from
the few trees in Alton Park Place.
In these moments we learn the highest, best in life: that which
comes not from our own efforts but is the gift of God.
Clarence D. Blachly.

Chicago.
AN INVITATION FROM CUBA
To the Editor:

The Woman’s Club of Havana would be very grateful if when social


workers of the United States anticipate visiting our city they would
kindly let us know as we want to avail ourselves of any opportunity to
get in touch with their work.
Our club is young and working under unusual circumstances. It is
composed of Cubans and Americans. A cordial welcome and
appreciative hearing would be given to any one willing to help us by
speaking before the club.
We feel that all such courtesies not only strengthen the union
between our countries but make for the better understanding and
development of both.
Ione R. Van Gorden.

[Secretary Woman’s Club of Havana.]


SHOPPERS’ PUZZLE
In reading The Survey of March 29, I was interested in the
Shoppers’ Puzzle on page 913. It certainly seems unfair to people
employed all during the week in offices and factories to deprive them
of their only opportunity to do their shopping Saturday afternoons.
On the other hand while they are having their half holiday the clerks
who wait on them are deprived of the half holiday so much needed
during the hot summer months.
Would it not be possible, however, for the St. Louis Consumers’
League to arrange with the heads of the department stores to give the
customary half holiday on some other day—say Thursday or Friday?
I was in England last June and there was a great deal of discussion
in the papers over the enforcement of a law compelling a weekly half
holiday in every line of business. In London business was suspended
at 1 P. M. Saturday, but in Oxford we learned to our sorrow that the
closing day was Thursday.
One of our party being in need of a dentist one Thursday afternoon
we started out to find one about 2 o’clock. Not one was to be seen
until 9:30 Friday morning, we were told. “The next best thing, we
decided, would be to consult a druggist or “chemist,” but there again
we were met with barred doors and drawn curtains. Finally
appealing to a “bobby” we were directed to a shop where we could
ring a night bell and get some attention. When we told the chemist
that in America the drug stores were always open even when other
places of business were closed he said that in England it was against
the law. He also explained that the country towns in England had the
half holiday during the week as Saturday was the country market
day. In Winchester the closing day was Wednesday. This is offered as
one answer, though there may be better ones for this modern
industrial puzzle.
Jean Allison.

Allentown, Pa.
THE RINGING OF THE BELL
To the Editor:

In your issue of March 15, 1913, you describe the ringing of a bell,
every five minutes, to indicate the unearned increment of $1,000 in
New York city real estate. This corresponds to a yearly increase of a
little over $106,000,000. As stated further on, however, the
community takes over $57,000,000 of this, directly, in taxes. It is
perfectly true that the industries of the city account for the increase
in value. But, on the other hand, the men who own and have built
skyscrapers on the land have made the space in which the
community lives. The land area itself is utterly inadequate for the
business and living room of the community. There does not seem to
be any great injustice in leaving for the men who have bought and
improved and who manage this land, between 40 and 43 per cent of
the increase, especially as the increase is itself subject to an increased
assessment and progressive taxation.
Looking at the matter in another way, the owner of land in New
York is allowed a trifle over 1½ per cent a year interest on his
investment. Unless he makes a high rate of interest on the buildings,
and the general experience for most cities is that 5 per cent on a
realty investment is rather beyond the average, it does not appear
that his profits are usurious.
A comparatively small fraction of the great fortunes of the country
is invested in realty, and for the country as a whole real estate is the
safeguard of the poor but thrifty. To reduce rents below the average
interest on conservative investments is to discourage thrift and home
owning. Temporarily and to a small degree increase of land tax will
stimulate building and thereby, by disturbing the relation of supply
and demand, reduce rents. But this effect will last only until those
who hold unsalable land have made the best of a bad investment. No
one will continue to engage in any kind of a business beyond the
point at which it yields a return fairly equivalent to that obtainable in
other lines.
It is almost an axiom that 4 per cent of the total cost of any kind of
a building must be allowed for taxes, insurance, repairs,
depreciation, &c. As much as 9 or 10 per cent of the investment must
therefore be charged in rentals, to equal even quiet investments
which require very little personal attention. In a small town or in
suburbs, where the land value is about $200 for a twenty-foot front
lot, a cottage can be built, with proper plumbing and lighting
equipment, so as to represent a total investment of somewhat less
than $1,000. This corresponds to a yearly rental of $90, or
thereabouts. How far the enormously increased land value can be
counterbalanced by building on a large scale, but with inevitably
more expensive material, is a question to be carefully considered. But
the rental must be calculated on a business basis unless the problem
is solved by a frank reversion to charity.
While it is unfortunate that any one should be poor, it does not
seem strange that 30 per cent of the earnings of the very poor, in a
city where there is literally too little land for the inhabitants, should
go for a home. Rent nowadays often includes water, care of exterior
of premises, and sometimes heat and light. A generation ago 25 per
cent, without any of these extras, was considered a fair average for
the moderately well-to-do family.
A. L. Benedict, M.D.

[Editor Buffalo Medical Journal.]


Buffalo.
THE BABY GARDEN
To the Editor:

As long as most mothers were able to stay at home and personally


care for their babies, the care of children remained an individual
matter. But, present economic conditions which force so many young
mothers to earn a living away from their homes and babies, present
this problem. How shall these babies be adequately cared for, in their
mother’s absence?
The public nurseries are charitable institutions for the children of
the poor. The middle-class working women, who earn enough to pay
a little for the care of their babies, are not permitted to leave their
little ones in them. But, even if they are permitted to do so, no
intelligent mother would be willing to do so. For these nurseries
attempt to minister only to physical wants. Although the needs of the
child at infancy seem to be largely physical, we know, that from the
day of its birth, the infant is getting impressions and forming habits.
The manner in which we satisfy his needs, the habits which he forms
under our care, shape his future character,—and yet, the training of
the so-called trained nurses in charge of the average nursery, enables
them to attend to the physical needs only. We all realize the need of
professionally trained teachers for the kindergarten and school age.
Is it not equally important to have trained specialists at infancy, the
most important stage of Childhood?
Though the present day nurseries need improvement, their
charges fare better than those left at home, to the mercy of hired
servants. The collective work of an institution carries with it a sense
of social responsibility for those entrusted to its care. What sense of
responsibility can we expect from an ignorant hired servant? The
self-supporting mother of moderate means has no alternative. She
must either give up her work and sometimes deprive her family of
the necessities of existence or else abandon her babe to the hands of
an ignorant servant.
Women of means can hire trained specialists for their babies. The
poor are helped by settlement nurseries, but the intelligent self-
supporting mothers, such as school-teachers and journalists, are
utterly helpless, each groping blindly with her own individual
problem that can no longer be solved individually. These women,
while compelled to do a man’s work, never can have that singleness
of mind that a man has while attending to his business.
The problem faced by these mothers can be solved only by social
co-operative measures. The establishment of a new type of public
nursery to meet the demands of intelligent mothers is now under
way. To distinguish it from the prevailing nurseries it is to be called
“the baby garden.” The children are to be divided into the following
groups according to age: Infants of one year or less; babies from a
year to two years; those from two to four years. Only experts in baby
culture specially trained to meet the needs of each of these individual
groups are to be placed in charge. The baby garden will be
surrounded by open-air balconies so that the children may be out of
doors the greater part of the day. Mothers who are so tied up that
they cannot go to the doctor or the dentist or attend to their
necessary shopping for the family without dragging baby along, will
be permitted to bring their babies for a few hours each day.
It is hoped that in time such baby gardens will become either self-
supporting or public institutions. The plan here outlined has been
approved by a number of public-spirited people who have promised
to temporarily subsidize this baby garden provided fifty mothers
endorse the scheme by their readiness to enroll their babies. The
amount to be paid for the care of these babies will be decided at a
meeting of the mothers who endorse the plan. All who are interested
may communicate with me at 516 East 78th Street.
[Mrs.] A. Levitas.

New York.
ILLUSTRATED IMMORALITY
To the Editor:

I want to get together a collection of pictures from which to make


slides for a lecture on illustrated immorality in its relation to our
people, to the city and to the state. Will you not publish this letter
asking for suggestions from your readers. To give an idea of my
purpose I have on my list the Laocoön, St. Michael and the Dragon
and St. George, Sir Galahad, Circe and the Swine, the triumphal
march of Bacchus, a picture published by the Chicago Tribune last
September illustrating the tale of a white slave, and a most effective
picture used widely in Atlanta of a hideous monkey-man beast
carrying the body of a girl under one arm and a bludgeon in the other
hand.
I want more symbolical pictures like these and I want also pictures
representing actual conditions in our cities, depicting perhaps the
temptations to the young. With the latter I would have to have some
exact information. I include, of course, the saloon in the scope of my
interests as I see no distinction between the twin evils, the saloon
and the bawdyhouse.
Howard A. Kelly, M.D.

Baltimore.
WORKMEN’S COMPENSATION: MR. JONES
ANSWERED
To the Editor:

So it seems that my fellow “Socialist agitators” and I are leading


around by their noses such staid and proper citizens as are to be
found in the City Club of New York, the New York Federation of
Labor and the American Association for Labor Legislation.[5] And
because some of us are advocating here and now in New York that
employers shall be permitted self-insurance, mutual insurance or
contribution to a state managed fund, we are “seeking to destroy
private business in all its forms.” But F. Robertson Jones, who is one
of those “employes of the casualty companies who have their bread
and butter at stake,” really need not be so perturbed. No one really
proposes “to transfer their jobs to political appointees and to leave
them out in the cold.” That is a “pure figment of the imagination” to
make use of Mr. Jones’ own restrained language. There are many
good men working for the state now and there will be more when Mr.
Jones and his fellow-employes are taken over to apply to the public
good the experience and knowledge gained in private enterprises.
And if public service is too contaminating, there will still be the self
insurers, and the mutuals in which those left “out in the cold” may
find ready employment. Let me hasten to add that I do not make this
statement “sneeringly” and that I hope a sober consideration of it
will carry conviction that if untrue, at least it is not “unqualifiedly
untrue.”
One example will do as well as a dozen to illustrate my point about
the attitude of the casualty companies toward “elective” acts. It is
well known that those companies opposed the New Jersey “elective”
act at the start. Seeing its tremendous advantages they then became
active in its support. As illustrating this point, I need only refer to the
energy and insistence with which the officers and counsel of various
casualty companies tried to put through, in the closing days of the
session last year in New York, a bill fashioned on the New Jersey
model. A special message from the governor and a special session of
the Legislature were talked of and only the uncompromising
persistence of the State Federation of Labor and the American
Association for Labor Legislation saved the employes of this state
from something even worse than the New Jersey act. The author of
that proposed New York bill, when it emerged from the conference
called by certain casualty officials and attorneys disowned it, it was
so bad.
The Pennsylvania commission is an example of a commission
advised by more than casualty company actuaries. Of that act a
commissioner from another state writes: “The Pennsylvania act is
calculated to turn the employe over to the “Shylocks” and loan sharks
in the liability business. The report of the Pennsylvania commission
outlines the most abominable act that it has been my privilege to
examine, and it fully maintains the reputation of the state of
Pennsylvania as being the ‘rotten borough’ of the world.”
No facts are quoted to prove that my statement as to the club
feature is “diametrically the opposite of the truth.” If the scheme
does not work out to the advantage of the casualty companies it
would be interesting to know why not. We would all agree that what
the companies most desire is that they shall get the employers, “or all
large employers,” to “come permanently under the compensation
feature or to stay out permanently”—exactly my point. Under such
happy circumstances prospective profits are beyond the dreams of
avarice. Maybe the profits have not been made yet, certainly I have
not so stated, It is the prospect which is so alluring, the profits so
nearly within grasp which are now slipping through their very
fingers, because of these “ill-advised enthusiasts” and other
undesirable citizens.
And is it, then, “a purely gratuitous misstatement of the fact” that
the casualty companies opposed, tooth and nail, the Ohio
compulsory act which, by the way, does not give a monopoly to
political boards? Do they not oppose such an act here in New York
today? Have they not opposed it in Iowa, California and
Washington?
As to the casualty companies having been most active “for a
constitutional amendment in New York,” so far as I have observed,
that activity has been very largely confined, as has that of certain
lawyers, to advocating such changes in the amendment as would
defeat the whole broad purpose of last year’s amendment. If listened
to by the Legislature these advocates would have put off for another
three years the much to be desired amendment to our constitution.
The objections to the fixing of rates by the insurance department
are two-fold. First, that that department is not “composed of officials
expert” in casualty insurance; second, that Senator Foley at the
public hearing at Albany, in order to meet the criticism of the
American Federation of Labor, proposed a state fund divorced from
the state insurance department. This was an important concession to
labor and was so intended. Labor and many others had fears of the
state insurance department, remembering the influence of the
insurance interests before Superintendent Emmett took charge and
fearing their influence after his retirement. That the “constitutional
objections have been carefully considered and that the overwhelming
weight of opinion is that they are not valid” is, as Mr. Jones would
say, “a purely gratuitous misstatement of the facts,” “a figment of the
imagination,” if not, indeed, “a gratuitous insult” to our intelligence.
A few lawyers retained by the casualty insurance companies may
disagree with us, but that hardly makes such a weight of opinion as
to be overwhelming. As to bar associations, all that is needed is to
look up the clients of some of these association committeemen. If
what is wanted is a duly attested power of attorney of the casualty
companies, I must admit that I cannot produce it.
If the Foley bill be studied with a little more care and with some
understanding of the lengths to which insurance agents will go and
have recently been going in Wisconsin, to misrepresent the state
fund, the statement about turning over the rich New York field may
not appear as such “nonsense.” It is to be remembered, too, that at
the time the Foley bill was introduced, the accompanying bill
providing for the organization of mutuals made such organization a
matter of extreme difficulty. This has been somewhat remedied
lately, more or less at the instigation, I fear, of the aforementioned
enthusiasts and Socialists.
The men who were openly planning the rout of the casualty
companies at the time I wrote were the State Federation of Labor, of
course. To that valiant and determined host has now been added the
American Association for Labor Legislation, the Progressive Party in
which ex-Superintendent of Insurance Hotchkiss is so important a
figure and Colonel Roosevelt.
Paul Kennaday.

New York.
JOTTINGS

PRUSSIAN COLONIZATION
Six million dollars will be spent by Prussia this year for the
cultivation and colonization of moor lands by farmers and
agricultural laborers. Part of the money will be used to provide cheap
credit to settlers.
GALSWORTHY ON THE EAST SIDE AGAIN
Because of its local appeal a performance of Galsworthy’s Strife is
being given by the Madison Square Church House at the Murray Hill
Lyceum, 160 East 34th Street, New York. [April 25.] The men and
boys in the cast have been trained by Jean Marcet and Inez
Milholland. Members of the Barnard College Dramatic Club take the
female parts.
FROM MOTORS TO FORKED-STICKS
Modern progress and practices which savor of the middle ages
sometimes go hand in hand, says the Engineering News. A press
dispatch from a city in the Canadian Northwest states that the city
council had voted to buy a motor-driven chemical and hose wagon,
and at the same meeting decided to engage a water finder hailing
from Hamiota to “make a thorough investigation with his magnetic
instrument of all possible sources of water supply.”
SOCIAL SERVICE WORK FOR GIRLS
The Department of Social Service of the Girls Friendly Society
offers a well worked out program for practical study and work by an
“associate” of the department. The program begins, it may be said in
passing, with a recommendation to subscribe to The Survey. Other
general recommendations are that the associate inform herself about
social work, especially among women and children; that she
cooperate with established societies and with such movements as
that for early shopping; that she recommend to her local group the
circulation among the membership of copies of state laws affecting
women and children, and arrange for conferences on social topics,
both formal and informal.
The Girls Friendly Society has a membership of 44,000, in 700
locals scattered throughout the country.
JEWISH FEDERATION IN DENVER
The Jewish Social Service Federation of Denver has been made a
permanent organization. It will work in the field covered by United
Hebrew Charities in other cities. It is primarily a federation for the
centralized collection of funds for Jewish societies.
The following organizations constitute the federation: Jewish
Relief Society, Jewish Ladies’ Aid Society, Denver Sheltering Home
for Jewish Children, Jewish Free Loan Society, Hachnosos Orchim
Society, philanthropic committee of the Council of Jewish Women,
Ladies’ Shroud Sewing Society and the Moas Chittim Society.
The beneficiaries of the federation include the National Jewish
Consumptives’ Hospital at Denver; the Jewish Consumptives’ Relief
Society at Denver; the Jewish Orphan Asylum at Cleveland, and the
Sir Moses Montefiore Kesher Home for Aged and Infirm Israelites at
Cleveland.
DETAINING THE DEFECTIVE DELINQUENT
The province of Ontario, Canada, is trying to provide a means for
more adequately handling the delinquent girl or woman who is also
feeble-minded or suffering from venereal disease. It is well known
that a third or a fourth of the boys and girls sent to reformatories are
mentally deficient, but in many places there is no legal treatment for
them except that of the reformatory which is designed for normal
people.
An act now before the Ontario legislature provides that any female
between the ages of fifteen and thirty-five who has been sent to an
industrial refuge, which is a house of correction, and who is
discovered to be so feeble-minded that she can not take care of
herself shall be kept in the refuge until the medical officer, with the
approval of the inspector, orders her discharge. All girls found to
have venereal diseases, or to be suffering from contagious or
dangerous illnesses, are to be kept in the refuge until they have fully
recovered.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like