I would like to average across “Rows” in a column. That is rows that have the same value in another column.
For example :
e= {{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2},
{69, 7, 30, 38, 16, 70, 97, 50, 97, 31, 81, 96, 60, 52, 35, 6,
24, 65, 76, 100}}

I would like to average all the Value in the second column that have the same value in the first one.
So Here : The Average for Col 1 = 1 & Col 1 = 2
And then create a third column with the result of this operation. So the values in that columns should be the same for the first 10 lines an next 10.
Many Thanks for any help you could provide !
LA
Output Ideal Format :

Interesting problem. This is the first thing that came into my mind:
To get rounding you may simply add
Round@beforeMeanin the code above:Round@Mean@#2Here is a slightly faster method, but I actually prefer the
Sow/Reapone above:If you have many different elements in the first column, either of the solutions above can be made faster by applying
Dispatchto the rule list that is produced, before the replacement (/.) is done. This command tells Mathematica to build and use an optimized internal format for the rules list.Here is a variant that is slower, but I like it enough to share anyway:
Also, general tips, you can replace:
Table[RandomInteger[{1, 100}], {20}]withRandomInteger[{1, 100}, 20]and
Join[{c}, {d}] // TransposewithTranspose[{c, d}].