Try this > ltr<-LETTERS[1:3] > unique(apply(expand.grid(ltr,ltr,ltr),1,function(x) > paste("Var",unique(sort(x)),collapse="+",sep=""))) [1] "VarA" "VarA+VarB" "VarA+VarC" "VarA+VarB+VarC" "VarB" "VarB+VarC" "VarC" >
Andrej -- Andrej Blejec National Institute of Biology Vecna pot 111 POB 141, SI-1000 Ljubljana, SLOVENIA e-mail: andrej.ble...@nib.si URL: http://ablejec.nib.si tel: + 386 (0)59 232 789 fax: + 386 1 241 29 80 -------------------------- Organizer: Applied Statistics 2011 conference http://conferences.nib.si/AS2011 > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Santiago Guallar > Sent: Monday, September 12, 2011 2:45 PM > To: r-help@r-project.org > Subject: [R] Automated generation of combinations > > Hello, > > I'd like to generate automatically all the possible combinations of a set of > 8 variables (there are 535, too many to do it by hand). For example: > > input: varA, varB, varC > output: varA+varB+varC > varA+varB > varA+varC > varB+varC > varA > varB > varC > Is there any function that produces this option? > > Thank you > [[alternative HTML version deleted]] ______________________________________________ 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.