Given a vector of stock ticker symbols:
sp500 <- c("ABT", "ANF", "ADBE", "AMD", "AES", "AET" .. )
How do I find all unique combinations of these for a portfolio of N assets? So for example if N=3 I'd like to return a table/matrix:
A1 | A2 | A3
--------------------------
"ABT" "ANF" "ABDE"
"ABT" "AMD" "ABDE"
"ABT" "AMD" "AES"
. . .
. . .
"YHOO" "YUM" "ZMH"
The order does not matter, so it's a "combination" rather than a "permutation", I believe.. I'm attempting to use R for this.
Advice on which function/method I might use for this would be much appreciated.