Created
June 18, 2012 20:48
-
-
Save jennifersmith/2950622 to your computer and use it in GitHub Desktop.
hacky_data_stuff.clj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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