Skip to content

Instantly share code, notes, and snippets.

@ryanbriones
Created August 8, 2012 04:44
Show Gist options
  • Save ryanbriones/3292129 to your computer and use it in GitHub Desktop.
Save ryanbriones/3292129 to your computer and use it in GitHub Desktop.
Chicago Open Data Hack Night R Demo in Incanter
;; 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
Copy link

awesome! the fit line looks a bit different than what we came up with. wonder why.

@ryanbriones
Copy link
Author

@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.

@ryanbriones
Copy link
Author

@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