Hello, I have a sequence of numbers: seq(1:50) and I would like to have all the possible combinations with this numbers without repeating any combination: 11, 12, 13, ... ,22,23,24,... How can I do it? Best, Dani -- Daniel Valverde Saub? Grup de Biologia Molecular de Llevats Facultat de Veterin?ria de la Universitat Aut?noma de Barcelona Edifici V, Campus UAB 08193 Cerdanyola del Vall?s- SPAIN Centro de Investigaci?n Biom?dica en Red en Bioingenier?a, Biomateriales y Nanomedicina (CIBER-BBN) Grup d'Aplicacions Biom?diques de la RMN Facultat de Bioci?ncies Universitat Aut?noma de Barcelona Edifici Cs, Campus UAB 08193 Cerdanyola del Vall?s- SPAIN +34 93 5814126
Try this: apply(expand.grid(1:50, 1:50), 1, paste, collapse = '') On Tue, Feb 17, 2009 at 8:37 AM, Dani Valverde <daniel.valverde@uab.cat>wrote:> Hello, > I have a sequence of numbers: > seq(1:50) > and I would like to have all the possible combinations with this numbers > without repeating any combination: > 11, 12, 13, ... ,22,23,24,... > How can I do it? > Best, > > Dani > > -- > Daniel Valverde Saubí > > Grup de Biologia Molecular de Llevats > Facultat de Veterinària de la Universitat Autònoma de Barcelona > Edifici V, Campus UAB > 08193 Cerdanyola del Vallès- SPAIN > > Centro de Investigación Biomédica en Red > en Bioingeniería, Biomateriales y > Nanomedicina (CIBER-BBN) > > Grup d'Aplicacions Biomèdiques de la RMN > Facultat de Biociències > Universitat Autònoma de Barcelona > Edifici Cs, Campus UAB > 08193 Cerdanyola del Vallès- SPAIN > +34 93 5814126 > > ______________________________________________ > 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. >-- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O [[alternative HTML version deleted]]
Hi Dani, see ?combn . combn(1:50,2) gives you all combinations as matrix. you can do sth like apply(combn(1:50,2),2, paste, sep="", collapse="") to get concatenated results. hth. Dani Valverde schrieb:> Hello, > I have a sequence of numbers: > seq(1:50) > and I would like to have all the possible combinations with this > numbers without repeating any combination: > 11, 12, 13, ... ,22,23,24,... > How can I do it? > Best, > > Dani >-- Eik Vettorazzi Institut f?r Medizinische Biometrie und Epidemiologie Universit?tsklinikum Hamburg-Eppendorf Martinistr. 52 20246 Hamburg T ++49/40/42803-8243 F ++49/40/42803-7790
Eik Vettorazzi wrote:> Hi Dani, > see ?combn . > > combn(1:50,2) > gives you all combinations as matrix. > you can do sth like > > apply(combn(1:50,2),2, paste, sep="", collapse="")note that you could simplify the above by combn(50, 2, paste, collapse = "") Best, Dimitris> to get concatenated results. > > hth. > > Dani Valverde schrieb: >> Hello, >> I have a sequence of numbers: >> seq(1:50) >> and I would like to have all the possible combinations with this >> numbers without repeating any combination: >> 11, 12, 13, ... ,22,23,24,... >> How can I do it? >> Best, >> >> Dani >> >-- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014