1.2.3-SNAPSHOT Arrow_down_16x16

with-data

incanter.core

  • (with-data data-binding & body)
Binds the given data to $data and executes the body.
Typically used with the $ and $where functions.

Examples:
(use '(incanter core stats charts datasets))

(with-data (get-dataset :cars)
(def lm (linear-model ($ :dist) ($ :speed)))
(doto (scatter-plot ($ :speed) ($ :dist))
(add-lines ($ :speed) (:fitted lm))
view))

;; create a dataset where :speed greater than 10 or less than -10
(with-data (get-dataset :cars)
(view (-> ($where {:speed {:$gt 20}})
(conj-rows ($where {:speed {:$lt 10}})))))

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/core.clj:2057 top

(defmacro with-data 
  "Binds the given data to $data and executes the body.
   Typically used with the $ and $where functions.
 
  Examples:
    (use '(incanter core stats charts datasets))
  
    (with-data  (get-dataset :cars)
      (def lm (linear-model ($ :dist) ($ :speed)))
      (doto (scatter-plot ($ :speed) ($ :dist))
                (add-lines ($ :speed) (:fitted lm))
                 view))

     ;; create a dataset where :speed greater than 10 or less than -10
     (with-data (get-dataset :cars)
       (view (-> ($where {:speed {:$gt 20}}) 
                       (conj-rows ($where {:speed {:$lt 10}})))))
 
"
  ([data-binding & body]
     `(binding [$data ~data-binding]
              (do ~@body))))
Vars in incanter.core/with-data: defmacro apply binding concat list seq vector
Used in 0 other vars

Comments top

No comments for with-data. Log in to add a comment.