Considering the following List :
answers = {
{{1, 2}, {7, 3}}, {{1, 3}, {6, 4}},
{{2, 1}, {2, 8}}, {{2,3}, {8, 2}},
{{3, 1}, {1, 9}}, {{3, 2}, {3, 7}}
}

Within the context of a task where subjects are sequentially presented 2 stimuli, having to choose the one they prefer, the first sublist :
{{1, 2}, {7, 3}}
can be read as
{{Cond1,Cond2}, {Cond1 Preferred Count,Cond2 Preferred Count}}
So when choosing 10 times between Cond1 & Cond2 when Cond1 is presented first, Cond1 is preferred 7 times out of 10.
**
I need to conditionally extract and/or
sum part of the list.
**
What I have been doing thus far:
To extract lists where Cond1 is presented first :
Select[answers, #[[1, 1]] == 1 &]
= {{{1, 2}, {7, 3}}, {{1, 3}, {6, 4}}}
And to get the total of count for one condition against all others :
Plus @@ Select[answers, #[[1, 1]] == 1 &][[All, 2]]
={13, 7}
Now, I need to :
Query the total count for Cond1 VS Cond2 & Cond2 VS Cond1 :
{{{1, 2}, {7, 3}},{{2, 1}, {2, 8}}}
would be the output
or total of count when Cond2 was presented first against Cond3 :
{{2,3}, {8, 2}}
Those are what I am missing.
There are 5 conditions total in reality
I like
Casesfor this, since I think the syntax comes out cleaner. Here’s one approach, using a couple of light utility functions: