Groups the given matrix by the values in the columns indicated by the
'on-cols' argument, returning a sequence of matrices. The returned
matrices are sorted by the value of the group column ONLY when there
is only a single (non-vector) on-col argument.
Examples:
(use '(incanter core datasets))
(def plant-growth (to-matrix (get-dataset :plant-growth)))
(group-on plant-growth 1)
;; only return the first column
(group-on plant-growth 1 :cols 0)
;; don't return the second column
(group-on plant-growth 1 :except-cols 1)
(def plant-growth-dummies (to-matrix (get-dataset :plant-growth) :dummies true))
(group-on plant-growth-dummies [1 2])
;; return only the first column
(group-on plant-growth-dummies [1 2] :cols 0)
;; don't return the last two columns
(group-on plant-growth-dummies [1 2] :except-cols [1 2])
;; plot the plant groups
(use 'incanter.charts)
;; can use destructuring if you know the number of groups
;; groups are sorted only if the group is based on a single column value
(let [[ctrl trt1 trt2] (group-on plant-growth 1 :cols 0)]
(doto (box-plot ctrl)
(add-box-plot trt1)
(add-box-plot trt2)
view))
Comments top
No comments for group-on. Log in to add a comment.