Is this what you want: > vector1 <- sample(LETTERS[1:6]) # randomize > vector2 <- letters[1:6] > # convert to lower case for matching > vector1 <- tolower(vector1) > vector2 <- tolower(vector2) > # count the number of matches so order does not matter > count <- match(vector1, vector2) > if (length(count[!is.na(count)]) == length(vector1)) print("match") else > print('no match') [1] "match" > vector1 <- sample(letters, 6) > vector1 [1] "d" "o" "t" "z" "g" "q" > count <- match(vector1, vector2) > if (length(count[!is.na(count)]) == length(vector1)) print("match") else > print('no match') [1] "no match" > >
On Mon, Jul 30, 2012 at 10:55 AM, Christofer Bogaso <bogaso.christo...@gmail.com> wrote: > 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@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. -- Jim Holtman Data Munger Guru What is the problem that you are trying to solve? Tell me what you want to do, not how you want to do it. ______________________________________________ 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.