M Rmail
M Rmail

Reputation: 9

Multiple list creation (R)

I'm stuck with a problem from 2 days now...

I have this simple list :

comp=list("ABN","WT","N")

And I want to create this multiple list :

comp=list(c("ABN","WT"),c("ABN","N"),c("WT","N"))

It's like a cartesian product but in a unique list.

I already tryed many code and search for packages but don't find anything.

Ths for help !

Upvotes: 0

Views: 45

Answers (1)

tushaR
tushaR

Reputation: 3116

You can use combn.

combn(x=unlist(comp),m=2,simplify=FALSE)

Upvotes: 2

Related Questions