1.2.3-SNAPSHOT permalink Arrow_down_16x16
  • (sweep x & options)
Return an array obtained from an input array by sweeping out a
summary statistic. Based to R's sweep function.

Arguments:
x is an sequence


Options:
:stat (default mean) the statistic to sweep out
:fun (defaul minus) the function used to sweep the stat out

Example:

(use '(incanter core stats))

(def x (sample-normal 30 :mean 10 :sd 5))
(sweep x) ;; center the data around mean
(sweep x :stat sd :fun div) ;; divide data by its sd

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:1844 top

(defn sweep
" Return an array obtained from an input array by sweeping out a
  summary statistic. Based to R's sweep function.

    Arguments:
      x is an sequence


    Options:
          :stat (default mean) the statistic to sweep out
          :fun (defaul minus) the function used to sweep the stat out

    Example:

      (use '(incanter core stats))

      (def x (sample-normal 30 :mean 10 :sd 5))
      (sweep x) ;; center the data around mean
      (sweep x :stat sd :fun div) ;; divide data by its sd

"
  ([x & options]
    (let [opts (when options (apply assoc {} options))
          stat-fn (or (:stat opts) mean)
          fun (or (:fun opts) minus)
          stat (stat-fn x)]
      (fun x stat))))
Vars in incanter.stats/sweep: defn let
Used in 0 other vars

Comments top

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