Hi,

I have a data file with n columns and r row.
The first 3 columns and the first 5 rows are:

2 3 1
1 6 X
4 0 X
X 8 X
5 X 5

The "X" means missing.
How could I write a script to calculate the average by column and
replace "X" with the average?

The output should be like:

2  3        1
1  6        3
4  0        3
3  8        3
5  4.25   5

For column 1, the counts excluding "X" is 4 with sum=12. So the
average for column 1 is 3.
For column 2, the counts excluding "X" is 4 with sum=17. So the
average for column 2 is 4.25.
For column 3, the counts excluding "X" is 2 with sum=6. So the average
for column 3 is 3.

Thanks!!!


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to