lapply(1:5, function(x) combn(groups, x)) or perhaps
unlist(lapply(1:5, function(x) combn(groups, x, FUN = paste, collapse = ", "))) Best, Ista On Wed, Aug 23, 2017 at 11:33 AM, Christofer Bogaso <bogaso.christo...@gmail.com> wrote: > Hi again, > > I am exploring if R can help me to get all possible combinations of > members in a group. > > Let say I have a group with 5 members : A, B, C, D, E > > Now I want to generate all possible unique combinations with all > possible lengths from that group e.g. > > 1st combination : A > 2nd combination : B > ..... > 5th combination : E > 6th combination : A, B > 7th combination : B, C > .... > last combination: A, B, C, D, E > > Ideally, I have a fairly large group so am looking for some > programmatic way to generate all possible combinations. > > Any help will be highly appreciated. > > Thanks for your time. > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.