Excuse me. This might be user specific question but I need your help. I have an indexed data, where positive integers are used for indexing data. I am trying to group data putting condition on index variable so that I can analyze group-wise data. But I don't know. Please guide me. Here is an example:
testdat = {{1, a11, b11}, {1, a12, b12}, {2, a21, b21}, {3, a31,
b31}, {4, a41, b41}, {2, a22, b22}, {3, a32, b32}, {3, a33,
b33}, {4, a42, b42}, {5, a51, b51}, {6, a61, b61}, {6, a62,
b62}, {5, a52, b52}, {5, a53, b53}, {5, b54, b54}};
If I do the following
GatherBy[testdat, First]
it groups data using first column as index. However, I want to group data in which rows indexed 1 and 2 should be one group, rows indexed 3,4 and 5 should be another group and row indexed 6 should be another group. Here is how the result should look like:
{{{1, a11, b11}, {1, a12, b12}, {2, a21, b21}, {2, a22, b22}}, {{3, a31, b31}, {3, a32, b32}, {3, a33, b33}, {4, a41, b41}, {4, a42, b42}, {5, a51, b51}, {5, a52, b52}, {5, a53, b53}, {5, b54, b54}}, {{6, a61, b61}, {6, a62, b62}}}
Another way to group the data would be to put rows indexed 1,2 and 3 into one group and rows indexed 4,5 and 6 into another group like in the following result:
{{{1, a11, b11}, {1, a12, b12}, {2, a21, b21}, {2, a22, b22}, {3, a31, b31}, {3, a32, b32}, {3, a33, b33}}, {{4, a41, b41}, {4, a42, b42}, {5, a51, b51}, {5, a52, b52}, {5, a53, b53}, {5, b54, b54}, {6, a61, b61}, {6, a62, b62}}};
This is just the theory. I need code to perform this job. I expect to hearing form Great guys form this community. Thank you in advance.