in reply to Re^2: transform a hash table into R dataframe or matrix with tab separator
in thread transform a hash table into R dataframe or matrix with tab separator

thx but i can find a good example to make work this module with a hash :(

  • Comment on Re^3: transform a hash table into R dataframe or matrix with tab separator

Replies are listed 'Best First'.
Re^4: transform a hash table into R dataframe or matrix with tab separator
by choroba (Cardinal) on Apr 01, 2016 at 22:05 UTC
    You just have to transform the hash into a reference to array of arrays.
    #!/usr/bin/perl use warnings; use strict; use Text::Table::Tiny qw{ generate_table }; my %periods = ( Mercury => { orbital => 0.24, rotation => 58.64 }, Venus => { orbital => 0.62, rotation => -243.02 }, Earth => { orbital => 1.00, rotation => 1.00 }, Mars => { orbital => 1.88, rotation => 1.03 }, Jupiter => { orbital => 11.86, rotation => 0.41 }, Saturn => { orbital => 29.46, rotation => 0.43 }, Uranus => { orbital => 84.01, rotation => -0.72 }, Neptune => { orbital => 164.8, rotation => 0.67 }, ); print generate_table( rows => [ [qw[ Planet Orbital Rotation ]], map [ $_, @{ $periods{$_} }{qw{ orbital rotation }} +], keys %periods ]);

    Data taken from Wikipedia.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,