Suppose I have an R vector of unique elements such as x <- c(1,2,3,4,5).
Is there a function to give me a list of all possible partitions of this vector x? I guess each partition would be a list of vectors, where each element in x belongs to one of the vectors. I want all possible partitions into any number of sets of any size.
(I think the number of such partitions is something like 2^n * n!, where n is the number of unique elements. I will probably not be using this function on vectors with more than 4 unique elements.)