dargosch has asked for the wisdom of the Perl Monks concerning the following question:

Greeting fellow monks!

I am working with some data that I store in a hash of arrays, which I would like to convert to a data.frame in the R statistical package using the RSPerl package.

In order for me to do that, I will have to convert the arrays in the hash to columns in an array[][].

My question for you all is: which array/matrix package would generally recommend for array transposing and/or array construction from columns?

Has anyone done any benchmarking on the various options?
Greatly appreciate all help!
  • Comment on Transpose an array and the perl equivalent of R cbind?

Replies are listed 'Best First'.
Re: Transpose an array and the perl equivalent of R cbind?
by gav^ (Curate) on Apr 25, 2002 at 01:06 UTC
    Perhaps if you used Data::Dump or Data::Dumper to output your data structure and posted a few lines somebody would be able to help.

    gav^

      Dumping my data in a post may not be such a good idea, since it involves a 10,000x100 array/matrix.

      I'll give you a hands-on example though:

      %myHash = (var1 => [1,2,3,4,5,6], var2 => [11,12,13,14,15,16]);
      is what I've got, and this is what I would like to have:
      @myArray = ([1,11], [2,12], [3,13], [4,14], [5,15], [6,16]);
      which of course would be converted to a data.frame in R (which is not part of the question, but I would of course be really thankful for fast and efficient Perl -> R code too).
        You may want to look at mapchar by tye.

        -Lee

        "To be civilized is to deny one's nature."