This function returns a sequence resulting from mapping the given function over
the value(s) for the given column key(s) of the given dataset.
Like other '$*' functions, it will use $data as the default dataset
if none is provided, where $data is set using the with-data macro.
Examples:
(use '(incanter core datasets))
(def cars (get-dataset :cars))
($map "speed" (fn [s] (/ s)) cars)
($map ["speed" "dist"] (fn [s d] (/ s d)) cars)
($map (fn [s] (/ s)) :speed cars)
($map (fn [s d] (/ s d)) [:speed :dist] cars)
(map (fn [s d] (/ s d)) ($ :speed cars) ($ :speed cars))
(with-data (get-dataset :cars)
(view ($map (fn [s] (/ s)) :speed))
(view ($map (fn [s d] (/ s d)) [:speed :dist])))
;; calculate the speed to dist ratio and append as new column to dataset
(with-data (get-dataset :cars)
(conj-cols $data ($map (fn [s d] (/ s d)) [:speed :dist])))
Comments top
No comments for $map. Log in to add a comment.