Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: HOW to calculate the column data

by Fletch (Bishop)
on Dec 03, 2009 at 21:10 UTC ( [id://810950]=note: print w/replies, xml ) Need Help??


in reply to HOW to calculate the column data

Since there's already been fish thrown . . . FORE!

perl -lane '/^N2O-(\d+)/;$t{$1}+=$F[-1];$c{$1}++;END{for(sort{$a<=>$b} +keys%t){printf"N2O-$_ %0.3f\n",$t{$_}/$c{$_}}}'

The cake is a lie.
The cake is a lie.
The cake is a lie.

Replies are listed 'Best First'.
Re^2: HOW to calculate the column data
by jwkrahn (Abbot) on Dec 03, 2009 at 21:33 UTC

    If you just want to make it short:

    perl -ane'$t{$F[0]}+=$F[1];$c{$F[0]}++}{printf"$_ %.3f\n",$t{$_}/$c{$_ +}for+sort+keys%t'

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-03-28 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found