# These two should yield the same results -----------------------------------
# Creating two random matrices
set.seed(89)
A <- rgraph_ba(t = 9, m = 4)
B <- rgraph_ba(t = 9, m = 4)
A;B
# Comparing
ans0 <- matrix_compare(A,B, function(a,b) (a+b)/2)
ans1 <- matrix(0, ncol=10, nrow=10)
for (i in 1:10)
for (j in 1:10)
ans1[i,j] <- mean(c(A[i,j], B[i,j]))
# Are these equal?
all(ans0[] == ans1[]) # Should yield TRUE
Run the code above in your browser using DataLab