Hello!

I have a regular data frame (DATA) with 10 people and 1 column
('variable'). Its cases are people with names ('a', 'b', 'c', 'd',
'e', 'f', etc.). I would like to write a function that would sum up
the values on 'variable' of all possible combinations of people, i.e.

1. I would like to write a loop - in such a way that it loops through
each possible pair of cases (i.e., ab, ac, ad, etc.) and sums up their
respective values on 'variable'

2. I would like to write a loop - in such a way that it loops through
each possible trio of cases (i.e., abc, abd, abe, etc.) and sums up
their respective values on 'variable'.

3.  I would like to write a loop - in such a way that it loops through
each possible quartet of cases (i.e., abcd, abce, abcf, etc.) and sums
up their respective values on 'variable'.

etc.

Then, at the end I want to capture all possible combinations that were
considered (i.e., what elements were combined in it) and get the value
of the sum for each combination.

How should I do it?
Thanks a lot!
Dimitri

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to