Skip to content

Commit b3cbef6

Browse files
committed
Update jaccards.R
1 parent 83d7e03 commit b3cbef6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

jaccards.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#This function finds Jaccard indices for each pair of sublists within two named vectors
2+
#The output is a dataframe containing all statistics relevant to the computation
3+
#Example named vector: list1 = list(one=c(1,2,3), two=c(2,3,4))
4+
15
jaccards <- function(list1, list2){
26
sapply(list1, function(x){
37
jacc <- sapply(list1, function(x) sapply(list2, function(y) length(intersect(x,y))/length(union(x,y))))
@@ -8,4 +12,4 @@ jaccards <- function(list1, list2){
812
len2 <- t(as.data.frame(lapply(list2, length)))
913
cbind(jacclong, List1=rep(len1, length(len2)), List2=rep(len2, length(len1)), Intersect=melt(intersects)[,3], Union=melt(unions)[,3])
1014
})
11-
}
15+
}

0 commit comments

Comments
 (0)