Given n sets, countIntersect computes the number of elements being shared by the individual n*(n-1)/2 pairs of sets.

countIntersect(..., logical = FALSE)

Arguments

...

several numeric or character vectors to intersect; alternatively, a data frame or matrix can be supplied, whose columns will be treated as individual sets

logical

should

Value

A matrix of size n*n. If logical==FALSE, on the diagonal, there are numbers of elements in each set, and at position i,j there is the number of elements in set j shared with set i. If logical==TRUE, on the diagonal, there are numbers of TRUEs in each set, and at position i,j there is the number of TRUEs shared by sets i and j.

Examples

countIntersect(1:2,1:3)
#> 1:2 1:3 #> 1:2 2 2 #> 1:3 2 3
countIntersect(c('a','b'),c('a','c'),c('b','c'))
#> c("a", "b") c("a", "c") c("b", "c") #> c("a", "b") 2 1 1 #> c("a", "c") 1 2 1 #> c("b", "c") 1 1 2