Created
August 8, 2012 04:44
-
-
Save ryanbriones/3292129 to your computer and use it in GitHub Desktop.
Chicago Open Data Hack Night R Demo in Incanter
This file contains 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
;; a naive implementation of the R intro demo from Chicago Open Data Hack Night | |
;; using clojure and incanter | |
;; | |
;; Data and explanation here: http://gathers.us/events/open-gov-hack-night-organized-by-open-city-ebf93 | |
;; | |
;; * Download incanter-latest (1.2 right now) | |
;; * run `script/repl` | |
;; * copy in code | |
(use '(incanter core io stats charts)) | |
(def nyc (read-dataset "../nyc_school_sat_scores_clean.csv" :header true)) | |
(def nyc-long (deshape :merge [:reading :writing :math] :data nyc)) | |
(def nyc-fit (linear-model ($ :reading nyc) ($ :math nyc))) | |
(view (histogram :reading :data nyc)) | |
(view (histogram :writing :data nyc)) | |
(view (histogram :math :data nyc)) | |
(with-data nyc | |
(doto (scatter-plot :math :reading :data nyc) | |
(add-lines ($ :math nyc) (:fitted nyc-fit)) | |
view)) |
@derekeder honestly, I had no idea what I was doing with that part. I had to fiddle with it a lot before I got it to look right. It's likely I'm using it wrong.
@derekeder updated; now produces the proper line on the scatter plot
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
awesome! the fit line looks a bit different than what we came up with. wonder why.