This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.

# GatherBy

 GatherBy gathers into sublists each set of elements in list that gives the same value when f is applied. GatherBygathers list into nested sublists using at level i.
• GatherBy evaluates for each i to determine how to gather the .
• GatherBy gives results that follow the ordering of elements in list.
• Within each sublist generated by GatherBy, elements appear in the same order as in list; the complete sublists are ordered so that their first elements appear in the same order as in list.
• GatherBy effectively produces an equivalence partition.
Gather data in odd and even lists:
Gather by remainder:
Gather by the first component in a vector:
Gather dates by year:
Gather by the first component and, within that, gather by the last component:
Use Framed to display grouping:
Gather data in odd and even lists:
 Out[1]=

Gather by remainder:
 Out[1]=

Gather by the first component in a vector:
 Out[1]=
 Out[2]=

Gather dates by year:
 Out[1]=
 Out[2]=

Gather by the first component and, within that, gather by the last component:
 Out[1]=
 Out[2]=
Use Framed to display grouping:
 Out[3]=
 Applications   (2)
Simulate some data:
Group elements based on the value of the second element:
Count the number of data points in each group:
Compute the means of the third element by group:
Group machine numbers by equivalence class based on rounding off the last tol bits:
Generate an unordered sample of distinct machine numbers close to 1:
Gather by equivalence class:
See how the factors in were grouped:
Here are the equivalence representatives and the values such that :
GatherBy[list] is equivalent to Gather[list]:
GatherBy is equivalent to Gather:
Gather the rows by Norm and display with the common norm of each group:
Compare to the result of Gather:
New in 7