[R] give all combinations
Martin Maechler
maechler at stat.math.ethz.ch
Tue Sep 2 17:01:47 CEST 2008
>>>>> "CW" == Carl Witthoft <carl at witthoft.com>
>>>>> on Mon, 01 Sep 2008 12:19:07 -0400 writes:
CW> I seem to be missing something here:
CW> given a set X:{a,b,c,whatever...}
CW> the mathematical definition of 'permutation' is the set of all possible
CW> sequences of the elements of X.
CW> The definition of 'combination' is all elements of 'permutation' which
CW> cannot be re-ordered to become a different element.
CW> example: X:{a,b,c}
CW> perm(X) = ab, ab, bc, ba, ca, cb
CW> comb(X) = ab, ac, bc
CW> So maybe a better question for this mailing list is: Are there
CW> functions available in any R package which produce perm() and comb()
CW> (perhaps as well as other standard combinatoric functions) ?
combn() has been "standard R" for quite a while now.
As others have mentioned in this thread (different branch of
same thread-tree), for permutations, one can typically easily
get what one wants via expand.grid() or outer() [or
mapply() .. ].
For that reason, those knowing R well haven't seen a big need
for a permutation() function.
Martin Maechler, ETH Zurich and R Core Team
More information about the R-help
mailing list