powered by
This function applies scaling to the columns of a data frame and computes and returns a distance matrix from a chosen distance measure.
compute_dmat( x, dist_method = "euclidean", apply_scaling = FALSE, subset_cols = NULL )
an object of class "dist" (see stats::dist())
stats::dist()
a numeric data frame or matrix
a distance measure to apply to the scaled data. Must be those supported by stats::dist(), plus "mahalanobis" and "cosine". Default is "euclidean".
"mahalanobis"
"cosine"
"euclidean"
use TRUE to apply base::scale(). By default does not scale data.
base::scale()
(optional) a list of columns to subset the data
dmat <- compute_dmat(iris, "euclidean", TRUE, c("Petal.Length", "Sepal.Length")) print(class(dmat))
Run the code above in your browser using DataLab