INCANTER
     の紹介
INCANTER
           の紹介

 Twitter : @Mozk_
 生物情報科学科 4年
は Clojure の上で動く
           っぽい何か
Clojure
は Java VM の上で動く
    LISPっぽい何か
LISPとは???
(defun local-similarity (a b) ;; a, b : sequence
  (declare (optimize (speed 3) (safety 0) (debug 0)))
  (let ((memo (make-hash-table :test 'equal)))
    (labels ((dp (x y)
               (declare (fixnum x y))
               (or #1=(gethash `(,x ,y) memo)
                   (setf #1#
                         (cond ((< x 0) 0)
                               ((< y 0) 0)
                               (:else   (let ((diagonal-local-distance
                                                (if (eql (elt a x)
                                                          (elt b y))
                                                    1
                                                    -1)))
                                           (max (+ diagonal-local-distance
                                                   (dp (1- x) (1- y)))
                                                (1- (dp (1- x) y))
                                                (1- (dp x (1- y)))
                                                0))))))))
      (iter outer (for x from 0 below (length a))
            (iter inner (for y from 0 below (length b))
                  (in outer (maximizing (dp x y))))))))
Lispははるか昔に作られた
        Javaよりも昔
          Cよりも昔
       Fortranよりも昔
    コンピュータよりも昔
        人類よりも昔
    地球ができるよりも昔
宇宙自体がLispプログラムであり
 本物のLisperがわざわざ実装
 しようとしないのも当然だ
 『Lispの真実』(http://www.aoky.net/articles/leon_bambrick/lisp_truth.htm)
熱狂的信者と括弧が多い言語


(defun fact (n)
   (if (= n 0)
       1
       (* n (fact (1- n)))))
前置きは終わりにして
Incanter.org   からダウンロード
立ち上げると
立ち上げると


    なんか、しょぼい・・・
おまじない:
(use '(incanter core stats charts))
簡単なことから

(def r (sample-normal 1000))
(view (histogram r))


 r ← rnorm(1000)
 hist(r)
見比べ!
どんどん比較
● (doc 'histogram)
● (find-doc “histogram”)




● ?hist
● ??hist
どんどん比較
●   (dataset [“x1” “x2”]
             [[1 2 3]
              [4 5 6]])

●   data.frame(x1 = c(1,2,3),
               x2 = c(4,5,6))
どんどん比較

●   (read-dataset “http://hoge.jp/a.csv”
                  :header true)

●   read.table(“http://hoge.jp/a.csv”,
               header = T)
基本的な部分では
だいたいRと対応する
  書き方がある!
Incanter
の利点
Javaとの親和性が高い!
(def output-stream
  (java.io.ByteArrayOutputStream.))
(save (function-plot sin -1 1)
      output-stream)
Javaとの親和性が高い!
(view (function-plot
        #(java.lang.Math/sqrt %)
        0 2))
柔軟
(with-data iris
  (view $data)
  (view ($ [:Sepal.Length :Sepal.Width]))
  (view ($ [:not :Petal.Width])))


(view ($data iris))
(view ($[:Sepal.Length :Sepal.Width] iris))
(view ($[:not :Petal.Width] iris)))
Clojureの純粋な拡張である

●   Incanterを使ってウェブアプリ
●   http://data-sorcery.org/
     2009/11/29/incanter-webapp/
欠点
ユーザ/パッケージが少ない
おわり
バイトでRのチュートリアル動画を作りました。
   http://togotv.dbcls.jp/20111107.html

Incanterの紹介