In R, I want to test if a pattern is present in a list, to replace an element located at the position in another list.
Let me take an example. My first list looks like this:
table 1:
[,1] [,2]
[1,]ABBABBCA
[2,]ABBUCCCH
My second list looks like this:
[,1] [,2]
[1,]KIGSPLOM
[2,]ANAMAKAM
I want to test the condition, if the pattern "KI" is present in my second list then replace the element at the same place in my first list.
In this case, KI is present in my second list in "KIGS" and I would replace "ABBA" by "KI". So in position [1,1] in both lists.
Is there a way to easily do that in Rand obtain the following list:
[,1] [,2]
[1,]KI BBCA
[2,]ABBUCCCH