Question: I have two vectors in R. list1

I have two vectors in R.

list1 <- c("ABCDEF", "FEDCBA", "AA-BB-CCCC", "ABCDEFGH-IJK", "ZZZZ")

list2 <- c("ABCDEF", "FEDCBA:XA", "AA-BB-CCCC-01", "AA-BB-CCCC-21:ABC", "ABCDEFGH-IJK-1X", "AKDWXFE-XXY")

I'd like to compare the two lists -- with list1 being the 'correct' list. If item in list1 does not appear in list2, then print out 'Add ___ (item in list1)'; if item in list2 is not in list1, then print out 'delete ___ (item in list 2)'. I would like to find partial matches. For example, list 1 has 'FEDCBA' and list2 has 'FEDCBA:XA" -- this would be an acceptable partial match....same with list 2 having AA-BB-CCCC-21:ABC while list1 has AA-BB-CCCC (this is also an acceptable partial match).

No loops, please.

This is for R programming. But please also, if able, provide an R code solution as well as a Python solution (and a VBA macro solution as well) -- with a strong preference being on providing an R programming solution.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!