[R] Combination

Eik Vettorazzi E.Vettorazzi at uke.uni-hamburg.de
Tue Feb 17 12:55:32 CET 2009


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




More information about the R-help mailing list