R/KtoDist.R

Defines functions KtoDist

KtoDist <- function(K) {
    dK <- diag(K)
    ones <- matrix(1, nrow = length(dK), ncol = 1)
    
    D <- tcrossprod(ones, dK) - 2 * K + tcrossprod(dK, ones)
    rownames(D) <- colnames(D) <- rownames(K)
    
    return(as.dist(sqrt(D)))
}

Try the CovCombR package in your browser

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

CovCombR documentation built on March 26, 2020, 7:15 p.m.