https://github.com/cran/EMCluster
Tip revision: 402bcb69315fa9c0ebffd3364b648523abf2b772 authored by Wei-Chen Chen on 05 September 2023, 10:00:02 UTC
version 0.2-15
version 0.2-15
Tip revision: 402bcb6
fcn_Jaccard.r
Jaccard.Index <- function(x, y){
xx <- as.vector(x)
yy <- as.vector(y)
if(length(xx) != length(yy)){
return("Error: x and y have different numbers of elements")
}
id <- (!is.na(xx)) & (!is.na(yy))
xx <- xx[id]
yy <- yy[id]
# xx[xx != 1] <- 0
# yy[yy != 1] <- 0
sum(xx == 1 & yy == 1) / sum(xx == 1 | yy == 1)
} # End of Jaccard.Index().