I believe there should be a way to calculate row averages.
My poorly-named @f array contains all the values for a given row, except for the 1st column. So, its probably a matter of creating a "row_tot" variable and using the existing @col_num array. Try it out.