Skip to content

Instantly share code, notes, and snippets.

@knjname
Last active December 19, 2015 12:59
Show Gist options
  • Select an option

  • Save knjname/5959155 to your computer and use it in GitHub Desktop.

Select an option

Save knjname/5959155 to your computer and use it in GitHub Desktop.
Incanter Example
/target
/lib
/classes
/checkouts
pom.xml
pom.xml.asc
*.jar
*.class
.lein-deps-sum
.lein-failures
.lein-plugins
.lein-repl-history
*~
#*

incanter-example

incanterの使用サンプル。

(ns incanter-example
(:use [incanter.core]
[incanter.io]
[incanter.charts]
[incanter.datasets]))
;;; Read a csv file.
(def crimeTable
;;; You can specify a URL or file path.
(read-dataset "http://hci.stanford.edu/jheer/workshop/data/crime/CrimeStatebyState.csv"
:header true))
;;; Shows the first 10 rows of crimeTable.
(head crimeTable)
;;; Filter dataset elements.
;; ["Alabama" "Violent Crime" "Murder and nonnegligent Manslaughter" 1960 406]
;; ["Alabama" "Violent Crime" "Murder and nonnegligent Manslaughter" 1961 427]
;; ["Alabama" "Violent Crime" "Murder and nonnegligent Manslaughter" 1962 316]
;; ...
(def alabamaViolentCrimes
($where {:State "Alabama" (keyword "Type of Crime") "Violent Crime"} crimeTable))
;; View a spreadsheet of crimeTable
(with-data crimeTable
(view alabamaViolentCrimes))
;;; Display the charts of alabamaViolentCrimes with JFrame.
(view
(with-data
($where {:Crime "Aggravated assault" :Year {:$gt 1995}} alabamaViolentCrimes)
(bar-chart ($map int :Year)
:Count
:title "Alabama's aggravated assault count since 1995"
:x-label "Count of crimes"
:y-label "Year")))
(defproject incanter-example "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.5.1"]
;; すげーJARをダウンロードしまくるよ
[incanter "1.4.1"]]
:source-paths ["."])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment