Dimitris Rizopoulos wrote:
you could try something like the following:
groups <- list(gp1 = 1:3, gp2 = 4:5, gp3 = 6:7,
gp4 = 8:10, gp5 = 11)
combn(5, 2, function (x) expand.grid(groups[x]), simplify = FALSE)
combn(5, 3, function (x) expand.grid(groups[x]), simplify = FALSE)
combn(5, 4, function (x) expand.grid(groups[x]), simplify = FALSE)
and this transforms it nicely into a single matrix
y <- combn(5, 2, function (x) as.matrix(expand.grid(groups[x])),
simplify = FALSE)
Reduce(rbind, y)
Bernd
______________________________________________
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.