Guest User

Untitled

a guest
Jan 16th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. dat = {{2, .1, .2}, {2, .2, .4}, {2, .3, .6}, {2, .4, .8}, {5, 1,
  2. 2}, {5, 2, 4}, {7, 20, 10}, {7, 40, 20}, {7, 60, 30}, {7, 80,
  3. 40}, {7, 100, 50}, {10, 30, 50}};
  4.  
  5. results = Table[N[Mean[Select[dat, #[[1]] == i &]]], {i, {2, 5, 7, 10}}];
  6.  
  7. Mean /@ GatherBy[dat, First]
  8.  
  9. Mean /@ GroupBy[dat, First]
  10.  
  11. MaximalBy[#, #[[2]] &] & /@ GatherBy[dat, First]
  12.  
  13. MaximalBy[#, #[[2]] &] & /@ GroupBy[dat, First]
  14.  
  15. Values @ GroupBy[dat, First, Mean]
  16.  
  17. Values @ Merge[Mean][Rule[#, {##}]& @@@ dat]
Add Comment
Please, Sign In to add comment