Compute distances from each item to group centroids
dist_to_centroids(d, g, squared = FALSE)
A distance matrix object of class dist
.
A factor representing the groups of items in d
.
If TRUE
, return the squared distance to group
centroids.
A data frame with distances to the group centroids:
A character vector of item labels from the dist object, or an integer vector of item locations if labels are not present.
The group for which the centroid distance is given. The column type
should match that of the argument g (the unique
function is used
to generate this column).
Inferred distance from the item to the centroid position of the indicated group.
This function computes the distance from each item to the centroid positions
of groups defined in the argument g
. This is accomplished without
determining the centroid positions directly; see the documentation for
dist_between_centroids
for details on this procedure.
If the distance can't be represented in a Euclidean space, the
CentroidDistance
is set to NaN
. See the documentation for
dist_between_centroids
for further details.