How to specify another method for the dist function in R?

The documentation for the dist function in R has the following words:

distance measurement method to be used. It must be one of the “Euclidean,” “maximum,” “Manhattan,” “Canberra,” “binary,” or “Minkowski.” Any unambiguous substring can be specified.

But I need to calculate the distance based on a custom function that is not in the list, is there any way to specify it? Or are there other ways besides the dist function suitable for my situation?

I know that I can do this in full, but I'm looking for a more accurate way to do this.

Thanks.

Edit:

The distance method I'm using is a correlation measure using pearson distance. Is there any way to do this?

+4
source share
1 answer

You can not; dist() only knows how to calculate specific distances. In R packets through CRAN, there are a large number of other distance / difference factors (including vegan , analogue and proxy , among many others.)

The latter, proxies , may be especially suitable for your needs. It not only has a large number of predefined coefficients, but also provides a structure for determining your own distance function, which is then called from the compiled code, so it is fast enough.

+8
source

All Articles