If you really don't want to use rdist
you could use dist
this is in stats and so part of base
dist(x, method = "euclidean")
e.g.
dist(rbind( c(1,2,3), c(3,2,1) ), method = "euclidean")
# this is the distance of the two vectors
题
I want to find out the euclidean distance of two matrices using the rdist()
function. It requires the fields package to be imported first. I am using R version 2.15.2 and unable to install this package as its giving error that package ‘fields’ is not available (for R version 2.15.2)
. Which package should I install?
解决方案
If you really don't want to use rdist
you could use dist
this is in stats and so part of base
dist(x, method = "euclidean")
e.g.
dist(rbind( c(1,2,3), c(3,2,1) ), method = "euclidean")
# this is the distance of the two vectors
其他提示
You need to downlaod R version 3.0(or higher)
and fields package
also has dependencies - You also need to install spam
and maps
,
Depends: R (≥ 3.0), methods, spam, maps