[Haskell-cafe] hmatrix-labeled: request for comments

adam vogt vogt.adam at gmail.com
Fri Feb 21 01:15:31 UTC 2014


Hi Nikita,

My package http://hackage.haskell.org/package/Rlang-QQ may be of
interest. Reading a data.frame into a HList of Vector, provided you
first coerce it to a list (as.list). That's a bit noisy if you look at
the first example of
<http://code.haskell.org/~aavogt/Rlang-QQ/examples/tests.hs>.

Another option would be to as.array the data.frame, to be able to read
it in as an array (repa or array). That limits you to having all
columns of the data frame be the same type. It should be
straightforward for RlangQQ to produce a LMatrix.

Regards,
Adam

On Wed, Feb 19, 2014 at 2:06 PM, Nikita Karetnikov
<nikita at karetnikov.org> wrote:
> 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
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list