Given the matrix
X1 X2 X3 X4 X5 [1,] 1 2 3 2 1 [2,] 2 3 4 4 3 [3,] 3 4 4 6 2 [4,] 4 5 5 5 4 [5,] 2 3 3 3 6 [6,] 5 6 2 8 4
I want to create a distance matrix containing the absolute average difference between each row of each column. For example, the distance between X1 and X3 should be = 1.67 if:
abs (1 - 3) + abs (2-4) + abs (3-4) + abs (4-5) + abs (2-3) + abs (5-2) = 10/6 = 1.67.
I performed the constructor function in the vegan package as follows:
designdist(t(test), method = "abs(AB)/6", terms = "minimum")
The resulting distance for columns 1 and 3 is 0.666. The problem with this function is that it sums all the values ββin each column and then subtracts them. But I need to summarize the absolute differences between each line (individually, absolutely), and then divide it by N.
source share