R/normw.R

Defines functions normw

Documented in normw

normw <- function(w) {
    # initialisation
    res <- dim(w)
    if (res[1] != res[2])
      stop("w is not a squared matrix")
    
    non.0 <- which(apply(w, 2, sum) != 0)
    w[non.0, ] <- w[non.0, ] / apply(w, 1, sum)[non.0]
    
    return(w)
  }
tibo31/GeoXp documentation built on April 8, 2023, 7:50 a.m.