# Distance between all the dots in a scatterplot in R [closed]

Is there any possibility in R to get a list of distances between all the points in a Scatterplot? For instance, this Scatterplot:

So, I would like to obtain a list of distances among all the points.

## closed as off-topic by Nick Cox, kjetil b halvorsen, Michael Chernick, mdewey, rolando2Feb 6 '18 at 19:59

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – Nick Cox, kjetil b halvorsen, Michael Chernick, mdewey, rolando2
If this question can be reworded to fit the rules in the help center, please edit the question.

check out the dist function.

 x <- c(1,2,3,6,3,6)
y <- c(4,5,7,8,9,0)
dist(cbind(x,y))


produces the following output.

     1        2        3        4        5
2 1.414214
3 3.605551 2.236068
4 6.403124 5.000000 3.162278
5 5.385165 4.123106 2.000000 3.162278
6 6.403124 6.403124 7.615773 8.000000 9.486833

• Perfect. And how could I reorder that matrix in two columns, the one on the left showing the two dots measured, and the one on the right the distances? – antecessor Feb 6 '18 at 12:54
• tmp <- dist(cbind(x,y)) now suppose $i > j$, the distance between point $i$ and point $j$ is stored in tmp[i-1][j]. – Siong Thye Goh Feb 6 '18 at 13:04