Database Reference
In-Depth Information
Getting ready
We'll use the same dependencies in our project.clj ile as we did in Creating scatter plots
with Incanter .
We'll also use this set of imports in our script or REPL:
(require '[incanter.core :as i]
'[incanter.charts :as c]
'[incanter.io :as iio])
For this chart, we'll use the mushroom dataset from the UCI machine learning archive. The
web page with the information about this dataset is at http://archive.ics.uci.edu/
ml/datasets/Mushroom , and we can download a copy of it with the header names directly
from http://www.ericrochester.com/clj-data-analysis/data/agaricus-
lepiota.data . I've downloaded it in a data directory, so I can load it with this expression:
(def shrooms
(iio/read-dataset "data/agaricus-lepiota.data"
:header true))
How to do it...
In order to graph this, we need to summarize the data in some way:
1.
Here, we'll get the number of mushrooms with a cap shape and create a bar chart
with that data:
(def shroom-cap-bar
(i/with-data
(->> shrooms
(i/$group-by :cap-shape)
(map (fn [[k v]] (assoc k :count (i/nrow v))))
(sort-by :cap-shape)
i/to-dataset)
(c/bar-chart :cap-shape :count)))
2.
Now we view it:
(i/view shroom-cap-bar)
 
Search WWH ::




Custom Search