Re: [R] Pairwise intersect comparisons of list elements

2008-11-20 Thread jim holtman
yet another way: > mapply(function(x,y)length(intersect(x,y)), q, w) [1] 0 1 3 3 On Thu, Nov 20, 2008 at 7:15 PM, Stefan Th. Gries <[EMAIL PROTECTED]> wrote: > Hi all > > I have two lists that have the same number of numeric vectors such as: > q<-list(1, 2:3, 4:6, 7:10) > w<-list(0, 1:2, 3:7, 8:

Re: [R] Pairwise intersect comparisons of list elements

2008-11-20 Thread jim holtman
try this: > q<-list(1, 2:3, 4:6, 7:10) > w<-list(0, 1:2, 3:7, 8:10) > result <- sapply(seq(length(q)), function(.indx) length(intersect(q[[.indx]], > w[[.indx]]))) > result [1] 0 1 3 3 > On Thu, Nov 20, 2008 at 7:15 PM, Stefan Th. Gries <[EMAIL PROTECTED]> wrote: > Hi all > > I have two lists t

[R] Pairwise intersect comparisons of list elements

2008-11-20 Thread Stefan Th. Gries
Hi all I have two lists that have the same number of numeric vectors such as: q<-list(1, 2:3, 4:6, 7:10) w<-list(0, 1:2, 3:7, 8:10) What I want to do is create a vector desired.result that looks like this but I am thinking there must be some kind of non-loop / "\\wapply" way to so ... desired.re