Skip to content

Instantly share code, notes, and snippets.

@tukachev
Created February 13, 2014 17:37
Show Gist options
  • Save tukachev/8980005 to your computer and use it in GitHub Desktop.
Save tukachev/8980005 to your computer and use it in GitHub Desktop.
# The Gower similarity index
# The Gower similarity index
gower <- function(p1, p2, max, min){
if (length(p1) != length(p2))
stop("'p1' and 'p2' must have the same length")
k <- length(p1)
range <- max - min
d <- sum(abs(p1 - p2) / range)
gs <- 1 - d / k
return(gs)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment