我想要均衡从原点到所有点的距离,其中点由具有两个坐标的数据帧给出。距离原点到空间中的点
我把所有的点为:
x y
1 0.0 0.0
2 -4.0 -2.8
3 -7.0 -6.5
4 -9.0 -11.1
5 -7.7 -16.9
6 -4.2 -22.4
7 -0.6 -27.7
8 3.0 -32.5
9 5.6 -36.7
10 8.4 -40.8
为了让我的应用欧几里得距离向量的距离。我曾经尝试这样做:
distance <- function(trip) {
distance = lapply(trip, function (x) sqrt((trip[x,]-trip[1,])^2+ trip[,x]-trip[,1])^2))
return(distance)
}
,这也:
distance = apply(trip,1, function (x) sqrt((trip[x,]-trip[1,])^2+ (trip[,x]-trip[,1])^2))
return(distance)
通过'DESIRED_DIST/DIST_FROM_ORIGIN'缩放点 – twentylemon