I have a nested list below.
{{{0.,0.,1.},1.},{{0.,0.1,0.9},1.},{{0.,0.2,0.8},1.},{{0.,0.3,0.7},1.},{{0.,0.4,0.6},1.},{{0.,0.5,0.5},1.},{{0.,0.6,0.4},1.},{{0.,0.7,0.3},1.},{{0.,0.8,0.2},1.},{{0.,0.9,0.1},1.},{{0.,1.,0.},1.},{{0.1,0.,0.9},68.6},{{0.1,0.1,0.8},68.6},{{0.1,0.2,0.7},68.6},{{0.1,0.3,0.6},68.6},{{0.1,0.4,0.5},68.6},{{0.1,0.5,0.4},68.6},{{0.1,0.6,0.3},68.6},{{0.1,0.7,0.2},68.6},{{0.1,0.8,0.1},68.6},{{0.1,0.9,0.},68.6},{{0.2,0.,0.8},136.2},{{0.2,0.1,0.7},136.2},{{0.2,0.2,0.6},136.2},{{0.2,0.3,0.5},136.2},{{0.2,0.4,0.4},136.2},{{0.2,0.5,0.3},136.2},{{0.2,0.6,0.2},136.2},{{0.2,0.7,0.1},136.2},{{0.2,0.8,0.},136.2},{{0.3,0.,0.7},203.8},{{0.3,0.1,0.6},203.8},{{0.3,0.2,0.5},203.8},{{0.3,0.3,0.4},203.8},{{0.3,0.4,0.3},203.8},{{0.3,0.5,0.2},203.8},{{0.3,0.6,0.1},203.8},{{0.3,0.7,0.},203.8},{{0.4,0.,0.6},271.4},{{0.4,0.1,0.5},271.4},{{0.4,0.2,0.4},271.4},{{0.4,0.3,0.3},271.4},{{0.4,0.4,0.2},271.4},{{0.4,0.5,0.1},271.4},{{0.4,0.6,0.},271.4},{{0.5,0.,0.5},339.},{{0.5,0.1,0.4},339.},{{0.5,0.2,0.3},339.},{{0.5,0.3,0.2},339.},{{0.5,0.4,0.1},339.},{{0.5,0.5,0.},339.},{{0.6,0.,0.4},406.6},{{0.6,0.1,0.3},406.6},{{0.6,0.2,0.2},406.6},{{0.6,0.3,0.1},406.6},{{0.6,0.4,0.},406.6},{{0.7,0.,0.3},474.2},{{0.7,0.1,0.2},474.2},{{0.7,0.2,0.1},474.2},{{0.7,0.3,0.},474.2},{{0.8,0.,0.2},541.8},{{0.8,0.1,0.1},541.8},{{0.8,0.2,0.},541.8},{{0.9,0.,0.1},609.4},{{0.9,0.1,0.},609.4},{{1.,0.,0.},677.}}
I want to split it into several lists if the second elements are same like below.
{{{0., 0., 1.}, 1.}, {{0., 0.1, 0.9}, 1.}, {{0., 0.2, 0.8},1.}, {{0., 0.3, 0.7}, 1.}, {{0., 0.4, 0.6}, 1.}, {{0., 0.5, 0.5},1.}, {{0., 0.6, 0.4}, 1.}, {{0., 0.7, 0.3}, 1.}, {{0., 0.8, 0.2},1.}, {{0., 0.9, 0.1}, 1.}, {{0., 1., 0.}, 1.}}
{{{0.1, 0., 0.9}, 68.6}, {{0.1, 0.1, 0.8}, 68.6}, {{0.1, 0.2, 0.7},68.6},{{0.1, 0.3, 0.6}, 68.6}, {{0.1, 0.4, 0.5},68.6},{{0.1, 0.5, 0.4}, 68.6},{{0.1, 0.6, 0.3},68.6}, {{0.1, 0.7, 0.2}, 68.6}, {{0.1, 0.8, 0.1},68.6},{{0.1, 0.9, 0.}, 68.6}}
{{{0.9, 0., 0.1}, 609.4}, {{0.9, 0.1, 0.}, 609.4}}
{{{1., 0., 0.}, 677.}}
I have tried Cases
, Split
, Part
without success. Your help is greatly appreciated.
Thank you in advance.
SplitBy[data, Last]
$\endgroup$SplitBy[data, #[[-1]] &]
, and you can change thePart
specification to suit your needs. $\endgroup$