I am trying to reverse the process presented here. Specifically, I need to go back to the original vector that generated a matrix of absolute distances between elements.
For example I have a NxN matrix named A (with people names on rows and columns), where each cell Aij has the value of |age_i-age_j|, representing the absolute difference in age between the two people i and j. I need to convert this matrix into a vector which reports the age of this N people.
The matrix could be:
A = matrix( c(0, 5, 42, 5, 0, 37, 42, 37, 0), nrow=3, ncol=3, byrow = TRUE)
and i want to transform it into this vector:
tmp <- c(18, 23, 60)
To go from the vector to the matrix I would have used this command:
A <- abs(outer(tmp, tmp, "-"))
what I'm trying to do is to reverse the process.