I'm trying to change the type of the values in my hash map (the hash-map contains data imported from a csv file, which imports everything as a string, creating this problem) from string to float:
Example Input:
(def toydata {"EGFR" ["12.34" "4.45" "1.32"], "MYCN" "5.11", "ABC9" ["3.21" "1.32"]})
What I want:
{"EGFR" [12.4 4.45 1.32] "MYCN" 5.11 "ABC9" [3.21 1.32]}
I found a great example here on SO by Thomas shown below, however it doesn't seem to work for map values that are vectors:
(defn remap [m f]
(reduce (fn [r [k v]] (assoc r k (apply f v))) {} m))
When I try to call this function on my map:
(remap toydata #(Float/parseFloat %))
I get an error:
ClassCastException clojure.lang.PersistentVector cannot be cast to java.lang.String
Can anyone help?