Hi, This has been asked before but not sufficiently answered from what I could find. How do you create combinations with repetitions (multisets) in R?
If I have > set <- array(1:3) And I want to choose all combinations of picking 2 numbers, I want to get a print out like [,1] [,2] [1,] 1 1 [2,] 1 2 [3,] 1 3 [4,] 2 2 [5,] 2 3 [6,] 3 3 subsets(set, 2, allow.repeat=T) should work, but I can't get the multic package to install, t(combn(set,2)) was suggested but it doesn't produce repetitions; expand.grid(rep(list(1:3), 2)) was also suggested, but it produces permuations, not combinations. Additionally, I would like to iterate through each resultant set for large n (similar to the description for getNextSet {pcalg}). Any suggestions? Reuben Cummings ______________________________________________ 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.