[R] testing whether two character vectors contain (the same) items in the same order

Federico Calboli federico.calboli at helsinki.fi
Thu Aug 6 12:25:56 CEST 2015


Hi All,

let’s assume I have a vector of letters drawn only once from the alphabet:

x = sample(letters, 15, replace = F)
x
 [1] "z" "t" "g" "l" "u" "d" "w" "x" "a" "q" "k" "j" "f" "n" “v"

y = x[c(1:7,9:8, 10:12, 14, 15, 13)]

I would now like to test how good a match y is for x.  Obviously I can transform the letters in numbers and use a rank test, but I was left wondering whether this is the only solution and whether there are more appropriate solutions that are already implemented in R (I am not going to reinvent the wheel if I can avoid it).

BW

F


--
Federico Calboli
Ecological Genetics Research Unit
Department of Biosciences
PO Box 65 (Biocenter 3, Viikinkaari 1)
FIN-00014 University of Helsinki
Finland

federico.calboli at helsinki.fi



More information about the R-help mailing list