[R] A "matching problem"

arun smartpink111 at yahoo.com
Mon Jul 30 20:08:59 CEST 2012


Not sure what you wanted.
But, this will be just a subset of possible combinations as you described in the post.

for(i in 1:length(vector1)){
 for(j in 1:length(vector2)){

  V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12
1  E  F  D  C  A  B  c  f  b   d   e   a
2  B  C  E  A  F  D  c  f  a   d   b   e
3  D  A  E  C  B  F  b  a  f   e   d   c
4  B  F  A  D  E  C  d  c  b   f   e   a
5  D  B  C  E  F  A  a  c  f   b   d   e
6  E  C  B  A  D  F  f  e  b   d   a   c


----- Original Message -----
From: Christofer Bogaso <bogaso.christofer at gmail.com>
To: r-help at r-project.org
Sent: Monday, July 30, 2012 10:55 AM
Subject: [R] A "matching problem"

Dear all, I was encountering with a typical Matching problem and was wondering whether R can help me to solve it directly.

Let say, I have 2 vectors of equal length:
vector1 <- LETTERS[1:6]
vector2 <- letters[1:6]

Now I need to match these 2 vectors with all possible ways like:

(A,B,C,D,E) & (a,b,c,d,e) is 1 match. Another match can be (A,B,C,D,E) & (b,a,c,d,e), however there cant be any duplication.

Is there any direct way to doing that in R?

Thanks and regards,

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list