-1
The question equation can be programmed as follows.
media_amos <- function(z, na.rm = TRUE){
if(na.rm) z[is.na(z)] <- 0
n <- nrow(z)
cmb <- choose(n, 2)
z[row(z) == col(z)] <- 0
sum(z)/(2*cmb)
}
x <- matrix(1:36, nrow = 6)
media_amos(x)
#[1] 18.5
mean(x)
#[1] 18.5
Thanks. It worked out.
– Fidel Henrique Fernandes