Skip to content

Instantly share code, notes, and snippets.

@jennifersmith
Created June 18, 2012 20:48
Show Gist options
  • Save jennifersmith/2950622 to your computer and use it in GitHub Desktop.
Save jennifersmith/2950622 to your computer and use it in GitHub Desktop.
hacky_data_stuff.clj
(ns git-charts.core
(:use [incanter.core] [incanter.zoo])
(:require (incanter stats charts io)))
(defn read-dataset []
(incanter.io/read-dataset "/Users/jen/Dropbox/legacy codebase/ove-gitstats/lines_of_code.dat" :delim \space))
(defn clean-dataset [ds]
(incanter.core/col-names ds [:Date :Locs]))
;; sure there is a more elegant way!
(defn downsample [window-size ds]
(let [downsampled (roll-mean window-size (sel ds :cols :Locs))]
(conj-cols (sel ds :cols :Date) downsampled)))
(defn create-chart [ds] (incanter.charts/time-series-plot :Date :Locs :x-label "Date" :y-label "Lines of code" :data ds))
(defn doitall [window-size]
(->> (read-dataset)
(clean-dataset)
(downsample window-size)
(clean-dataset) ;; ooops
(create-chart)
(view)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment