1.2.3-SNAPSHOT Arrow_down_16x16

detabulate

incanter.stats

  • (detabulate & options)
Take a contingency table of counts and returns a matrix of observations.

Examples:

(use '(incanter core stats datasets))

(def by-gender (group-on (get-dataset :hair-eye-color) 2))
(def table (matrix (sel (first by-gender) :cols 3) 4))

(detabulate :table table)
(tabulate (detabulate :table table))

;; example 2
(def data (matrix [[1 0]
[1 1]
[1 1]
[1 0]
[0 0]
[1 1]
[1 1]
[1 0]
[1 1]]))
(tabulate data)

(tabulate (detabulate :table (:table (tabulate data))))

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source incanter/stats.clj:2546 top

(defn detabulate
" Take a contingency table of counts and returns a matrix of observations.

  Examples:

    (use '(incanter core stats datasets))

    (def by-gender (group-on (get-dataset :hair-eye-color) 2))
    (def table (matrix (sel (first by-gender) :cols 3) 4))

    (detabulate :table table)
    (tabulate (detabulate :table table))

    ;; example 2
    (def data (matrix [[1 0]
                       [1 1]
                       [1 1]
                       [1 0]
                       [0 0]
                       [1 1]
                       [1 1]
                       [1 0]
                       [1 1]]))
    (tabulate data)

    (tabulate (detabulate :table (:table (tabulate data))))

"
  ([& options]
    (let [opts (when options (apply assoc {} options))
          table (:table opts)
          row-labels (when table (or (:row-labels opts) (range (nrow table))))
          col-labels (when table (or (:col-labels opts) (range (ncol table))))
          data (apply bind-rows
                      (apply concat
                             (for [r row-labels c col-labels]
                                  (repeat (sel table :rows r :cols c) [r c]))))]
       data)))
Vars in incanter.stats/detabulate: defn let
Used in 0 other vars

Comments top

No comments for detabulate. Log in to add a comment.