R/homoteneity.R

homoteneity <- function (comm,clustering) 
{
    clustering <- clustify(clustering)
    levels <- levels(clustering)
    clustering <- as.integer(clustering)

    numtyp <- length(table(clustering))
    homo <- rep(NA,numtyp)
    S <- mean(apply(comm>0,1,sum))
    const <- const(comm,clustering)
    for (i in 1:numtyp) {
        tmp <- as.numeric(rev(sort(const[,i])))
        homo[i] <- mean(tmp[1:S])
    }
    out <- data.frame(as.character(1:numtyp),homo)
    names(out) <- c('cluster','homoteneity')
    attr(out,'call') <- match.call()
    attr(out,'orig_clustering') <- levels
    out
}

Try the labdsv package in your browser

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

labdsv documentation built on April 10, 2023, 5:08 p.m.