This one has turned out to be a real brain teaser for me. I have 7 x 7 matrix, but the values are meaningless, so I'll just set them to zero:
mymat <- matrix(ncol=7,nrow=7, 0)
I want to measure the Euclidean distance from the center of this matrix to every other square in this matrix, and visualize the results in kind of a heatmap plot. Defining the center and distance function is easy:
I'm not sure where to go from here - but I'm thinking it would require a for loop over each index of the matrix applying the distance function, then to melt and plot with ggplot (since trying to plot the matrix itself would mess up the order of the rows/cols ?)