R/rclust.weights.R

Defines functions rclust.weights

Documented in rclust.weights

rclust.weights <-
function(groups, dist) {
  c <- length(table(groups))
  D <- as.matrix(dist)
  n <- dim(D)[1]
  weights <- matrix(,n,c)
  for (k in 1:n) {
    for (i in 1:c) {
      z <- which(groups==i)
      if (groups[k]==i) weights[k,i] <- sum(D[k,z])/(length(z)-1)
      else weights[k,i] <- sum(D[k,z])/length(z)
    }
  }
  return(weights)
}

Try the fossil package in your browser

Any scripts or data that you put into this service are public.

fossil documentation built on March 23, 2020, 5:06 p.m.