0

I have two vectors

v1<-c("T","A","G","R","A","G")
v2<-c("R","A","G,"T","A","G")

i want to find the longest matching subsequence. what i did is

 v<-match(v1,v2)

v [1] 4 2 3 1 2 3

expected output:

v [1] NA 2 3 NA 2 3

the longest should be 2 3 in either location corresponding to the "A" "G" but the match function labels the "T" in v2 as 1 in the match, so the longest match subsequence end up being 1 2 3 and thats not what i want

any help please ? is there a way to let match function have like a minimum match before it starts labeling

  • What is the expected output – akrun Aug 30 '20 at 22:27
  • v [1] NA 2 3 NA 2 3 – Sherif Negm Aug 30 '20 at 22:46
  • Why the longest subsequence is not 1 2 3 for last 3 values? I am not sure if I understand your question, can you create few more examples with expected output? – Ronak Shah Aug 31 '20 at 06:43
  • oh yes thank you so much LCS was a nice function. @RonakShah so if you look back at the dna strings you find that AG is the longest common substring but the match function messes up by putting 1 referring to the T in the first string – Sherif Negm Sep 01 '20 at 01:14

0 Answers0