[Haskell-cafe] hmatrix-labeled: request for comments
Nikita Karetnikov
nikita at karetnikov.org
Wed Feb 19 19:06:42 UTC 2014
I like how easy it is to import data in R and Octave. (See [1] for a
typical workflow.) Since I couldn’t find any matching library on
Hackage, I cooked up my own [2] in a couple of days.
Here’s an example. Let’s start by creating a poorly formatted dataset:
$ cat > test.txt
One Two Longish Four
Foo 1 -2 3.0 4.0
Looooooong 5.0 6.0 -72.0 8.0
Baz 41.0 4.2324234e7 43.0 1.111111144E-12
Then we parse it with ‘readFile’, mangle the data a bit, and display in
GHCi:
λ> import qualified Data.Packed.LMatrix.IO as L
λ> import qualified Data.Packed.LMatrix as L
λ> do m <- L.readFile "test.txt"; return . L.trans . L.reverseRows $ L.map (+1) m
(4><3)
Baz Looooooong Foo
One 42.0 6.0 2.0
Two 4.2324235e7 7.0 -1.0
Longish 44.0 -71.0 4.0
Four 1.0000000000011111 9.0 5.0
Now I’m wondering how to make it better. I’m planning to add the
documentation, augment the parser to accept CSV, and maybe support other
matrix libraries. What’s missing? Would you like to see it on Hackage?
And if not, why?
[1] http://astrostatistics.psu.edu/su09/lecturenotes/pca.html
[2] https://gitorious.org/hmatrix-labeled
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140219/2637de71/attachment.sig>
More information about the Haskell-Cafe
mailing list