R 三参数呼叫距离函数

R 三参数呼叫距离函数,r,parameters,distance,R,Parameters,Distance,我已经根据名为x1和x2的两个向量(个体)和第三个权重向量(w)定义了距离 。。。但它不起作用。 唯一的解决方案是使w.dist仅依赖于x1和x2 有什么想法吗?正如我之前提到的,与其将w作为参数传递,不如在函数w.dist中定义它 这就是我提到的las试验,但是当我并行化代码时,我在w识别方面遇到了问题。 w.dist <- function(w, x1, x2){ # Define y1 and y2 y1 <- x1/w y2 <- x2/w # Define t

我已经根据名为
x1
x2
的两个向量(个体)和第三个权重向量(
w
)定义了距离

。。。但它不起作用。 唯一的解决方案是使
w.dist
仅依赖于
x1
x2


有什么想法吗?

正如我之前提到的,与其将
w
作为参数传递,不如在函数
w.dist
中定义它

这就是我提到的las试验,但是当我并行化代码时,我在
w
识别方面遇到了问题。
w.dist <- function(w, x1, x2){
# Define y1 and y2
  y1 <- x1/w
  y2 <- x2/w
# Define the distance directly
  w.d <- sqrt(sum(w*(log(y1/w.geoM(w,x1)) - log(y2/w.geoM(w,x2)))^2))
# Return the value
  return(w.d)
}
  # Define the vector of weights 
    w <- c(2,rep(1,9))
  # Try to compute the distances
    DIST <- dist(x, method = w.dist)