Data={{0,5678},{0,5654},{1,87675},{2,243},{2,257},{1,9790},{0,7688},{1,97779},{0,6858}}
Given a data set similar to the above, how can I select rows where the first column entry is a number that I specify, and the following row is a row is where the first column entry is another number that I specify, and only alternating first column entries, for instance,
Choose 0 Choose 1
I'd like the output to be,
{{0,5678},{1,87675},{0,7688},{1,97779}}
Or if I do
Choose 1 Choose 2
I'd like the output to be,
{{1,87675},{2,243},}
etc.
So far, I have
Cases[Data,{n_,_}/;n>=1]
This doesn't quite do it, but it's a start. Thanks!
SplitBy[Select[Data, MatchQ[{0 | 1, _}]], First][[All, 1]]
? $\endgroup$