Hi,
I would like to calculate the average of column 'y' based on the value of column 'pos'.
For example, here is file1
id pos y c
11 1 220 aa
11 4333 207 f
11 5333 112 ee
11 11116 305 e
11 11117 310 r
11 22228 781 gg
11 33310 121 hhh
11 55511 981 rr
11 111112 22 e
...
What I wanted is to calculate the average of "y" based on "pos", specifically, I want the average of y for pos from 1-10000, 10001-20000, ..., and out put would look like,
outputfile
id pos mean.y
11 1 179.6667 because 179.6667=(220+207+112)/3
11 10001 307.5 307.5=(305+310)/2
11 20001 781 781=781/1
11 30001 121 121=121/1
11 40001 0 because there is no 'pos' from 40001 to 5000
11 50001 981
...
Thanks a lot!
Note, the 'pos' of the outputfile is the starting value of a range.