1.2.3-SNAPSHOT permalink Arrow_down_16x16

conj-cols

incanter.core

  • (conj-cols & args)
Returns a dataset created by merging the given datasets and/or collections.
There must be the same number of rows in each dataset and/or collections.
Column names are not preserved in order to prevent naming conflicts.

Examples:
(use '(incanter core datasets))
(def cars (get-dataset :cars))
(def x (sel cars :cols 0))
(view (conj-cols cars cars))
(view (conj-cols cars x))
(view (conj-cols (range (nrow cars)) cars))
(view (conj-cols (range 10) (range 10)))
(view (conj-cols {:a 1 :b 2} {:c 1 :d 2}))

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

(defn conj-cols
  "Returns a dataset created by merging the given datasets and/or collections.
   There must be the same number of rows in each dataset and/or collections. 
    Column names are not preserved in order to prevent naming conflicts.

    Examples:
      (use '(incanter core datasets))
      (def cars (get-dataset :cars))
      (def x (sel cars :cols 0))
      (view (conj-cols cars cars))
      (view (conj-cols cars x))
      (view (conj-cols (range (nrow cars)) cars))
      (view (conj-cols (range 10) (range 10)))
      (view (conj-cols {:a 1 :b 2} {:c 1 :d 2}))

"
  ([& args]
     (reduce (fn [A B] 
                    (let [a (to-dataset A)
                           b (to-dataset B)
                           ncol-a (ncol a)
                           ncol-b (ncol b)
                           colnames (map #(keyword (str "col-" %))
                                                    (range (+ ncol-a ncol-b)))]
                      (dataset colnames
                                    (map concat (to-list a) (to-list b)))))
             args)))
Vars in incanter.core/conj-cols: concat defn fn let map reduce
Used in 0 other vars

Comments top

No comments for conj-cols. Log in to add a comment.