Dear all:

This is one of those "should be easy" problems that I'm having great difficulty 
solving. I have a vector containing ID codes, and I need to generate a 3-column 
matrix that contains all possible combinations of three.

For example, my ID vector looks like this:
A
B
C
D
E

I need to generate a matrix that looks like this:
A B C
A B D
A B E
A C B
A C D
A C E
A D B
A D C
A D E
.... and so on. (Yes, this could yield some very large matrices!) It's totally 
fine, though less desirable, if the resulting matrix contains combinations with 
"duplicates," e.g., A A A, A A B, or whatever.

Thoughts? I'm pretty much stumped here. Thanks in advance for any help you can 
offer.

Best regards,

Brandon

______________________________________________
R-help@r-project.org 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