Take the 2-minute tour ×

I have an array of 12 objects. Each is a letter. I want to generate all combinations of 4,5,6,7 and 8 letters.

First I just generate the permutations using gregmisc:


Then I want to take the array of objects called letters.split and I want to create all combos. So I go:



It seems pretty computationally inefficient..takes a while. There must be a better way to use the permutation combos at an index. The permutations function isn't really what bothers me because I only have to do it ones then I can just save it.

I want to ask if there's a vectorized way of doing this but I don't actually know what that means I just hear it all the time, so a simple explanation of what a vectorized function is, in simple terms, would also go a long way with me!


share|improve this question
I'm not entirely clear what you're asking, though it seems like you may simply be trying to recreate the combn function? –  joran Jan 22 '12 at 2:27
The second step does not look necessary: the permutations function has a v argument that can directly permute your data, without having to consider the indices: lapply( 4:6, permutations, n=8, v=LETTERS[1:12] ). –  Vincent Zoonekynd Jan 22 '12 at 2:33
Ask "What is a vectorised function?" in a new question. –  Richie Cotton Jan 22 '12 at 17:28

Your Answer



Browse other questions tagged or ask your own question.