점들간의 거리 계산

P1 <- c(1,2,3)
P2 <- c(3,5,2)
P3 <- c(5,5,4)
P4 <- c(1,4,7)
P5 <- c(2,2,4)
df <- t(data.frame(
  P1, P2, P3, P4, P5
))
df_dist <- dist(df)
min(df_dist)
## [1] 1.414214
mat_dist <- as.matrix(df_dist)
which(mat_dist == min(df_dist), arr.ind = T)
##    row col
## P5   5   1
## P1   1   5