GatherBy and two conditions

I have a list of 4 dim points, given by

list={{0, 1/100, 6, 1/3}, {0, 1/100, 5, 1/3}, {0, 1/100, 6, 2/3}, {0, 1/
100, 5, 2/3}, {0, 1/100, 6, 1}, {0, 1/100, 5, 1}, {1/2, 0.0132789,
6, 1/3}, {1/2, 0.00603171, 8, 1/3}, {1/2, 0.0133361, 6, 2/3}, {1/2,
0.0059745, 8, 2/3}, {1/2, 0.0133552, 6, 1}, {1/2, 0.00595543, 8,
1}, {1, 0.0148608, 6, 1/3}, {1, 0.00444984, 8, 1/3}, {1, 0.0149013,
6, 2/3}, {1, 0.00440938, 8, 2/3}, {1, 0.0149147, 6, 1}, {1,
0.0043959, 8, 1}, {3/2, 0.0160638, 6, 1/3}, {3/2, 0.0032469, 8, 1/
3}, {3/2, 0.0160968, 6, 2/3}, {3/2, 0.00321387, 8, 2/3}, {3/2,
0.0161078, 6, 1}, {3/2, 0.00320286, 8, 1}}

I would like to gather the elements of the list using two conditions and then create a ListPlot of them. So the first two elements of each point should be the x y coordinates and the last two should be the conditions. The first condition should check if the thrid element is equal 6 and the second codition should group elements for 1/3, 2/3 and 1. I tried

GatherBy[list, {#[[3]] == 6, Last} &][[All, All, {1, 2}]]

but it takes into account only the first condition, giving me 2 lists of points. I wanted to have 6 lists of points in this example. Any ideas?

=================

  

 

It is not very clear what you are asking for and also you are using plotPointsX in place of list or some processed version of list?
– gpap
Mar 3 ’14 at 10:22

  

 

Thanks, I corrected the misunderstanding.
– wlq
Mar 3 ’14 at 10:27

=================

1 Answer
1

=================

I think this is what you’re asking for – question is a bit unclear:

Flatten[GatherBy[#, Last] & /@ GatherBy[list, #[[3]] == 6 &], 1]

As noted below, you can also use :

Join @@ GatherBy[list, {#[[3]] == 6 &, Last}]

But note the change in the pure-function ampersand position!

  

 

Thanks! This does exactly what I need. Thank you!
– wlq
Mar 3 ’14 at 10:27

  

 

+1 for good guesswork!
– gpap
Mar 3 ’14 at 10:30

1

 

You can gather into nested sublists using GatherBy[list, {#[[3]] == 6 &, Last}]
– Simon Woods
Mar 3 ’14 at 10:31

  

 

@SimonWoods: That was my first though, but produces completely different result from what OP appears to want. However a join should do the trick…
– ciao
Mar 3 ’14 at 10:35