I have two lists that contain S4
objects. Now I want to ask if an element of list_1 contains an element of list_2, like I do in the following example for lists of character vectors.
s<-list(a=LETTERS[1:3],b=LETTERS[4:6])
t<-list(n=LETTERS[1:3],v=LETTERS[1:4])
s %in% t
But does it prove if the objects are identical? If not, how to select the element of list_1 which exists in list_2 without using a loop?
If you want to compare S4 objects I believe you will have to use (as Ben Bolker suggested) a mixture of functions
slotNames
,slot
, andsapply
.And now if you want to extend that to a list of S4 objects, use on top of that Metrics solution: