I am running an analysis of a number of sets and I have been using the package VennDiagram, which has been working just fine, but it only handles up to 5 sets, and now it turns
OK, here's one way, assuming you represent sets as a list of vectors, and items to be searched in those sets also as vector:
# Example data format
sets <- list(v1 = 1:6, v2 = 1:8, v3 = 3:8)
items <- c(2:7)
# Search for items in each set
result <- data.frame(searched = items)
for (set in names(sets)) {
result <- cbind(result, items %in% sets[[set]])
names(result)[length(names(result))] <- set
}
# Count
library(plyr)
ddply(result, names(sets), function (i) {
data.frame(count = nrow(i))
})
This gives you all combinations actually existing in the itemset:
v1 v2 v3 count
1 FALSE TRUE TRUE 1
2 TRUE TRUE FALSE 1
3 TRUE TRUE TRUE 4