Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Descriptive Stats from .csv file

by korsmo (Initiate)
on Feb 03, 2014 at 18:14 UTC ( [id://1073249]=note: print w/replies, xml ) Need Help??


in reply to Re: Descriptive Stats from .csv file
in thread Descriptive Stats from .csv file

Hi,
That seemed to work well for obtaining the values I need - thanks! I have loaded the module Excel::Writer::XLSX to try to bring those values into a .xlsx file. Do you know if I need to put the cast_means and cast_stddev values into an array before I can write the .xlsx file?
Thanks again,
BK

Replies are listed 'Best First'.
Re^3: Descriptive Stats from .csv file
by kevbot (Vicar) on Feb 08, 2014 at 06:48 UTC

    You can use the Data::Table::Excel module to put the contents of a Data::Table object into an Excel file. From the documentation,

    This perl package provide utility methods to convert between an Excel file and Data::Table objects. It then enables you to take advantage of the Data::Table methods to further manipulate the data and/or export it into other formats such as CSV/TSV/HTML, etc.

    For example, this code will create an xlsx file that contains both the mean and stddev tables:

    #!/usr/bin/env perl use strict; use warnings; use Data::Table; use Data::Table::Excel qw(tables2xlsx); use Statistics::Lite qw(mean stddev); my $dt = Data::Table::fromCSV("data.csv"); my $melt = $dt->melt(['Month', 'Zone', 'Replicate']); my $cast_mean = $melt->cast( ['Month', 'Zone'], 'variable', Data::Table::STRING, 'value', \&mean ); my $cast_stddev = $melt->cast( ['Month', 'Zone'], 'variable', Data::Table::STRING, 'value', \&stddev ); tables2xlsx("descriptive_stats.xlsx", [ $cast_mean, $cast_stddev ]); exit;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1073249]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-24 09:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found