dist_to_centroids: Compute distances from each item to group centroids

Description Usage Arguments Details Value

Description

Compute distances from each item to group centroids

Usage

1
dist_to_centroids(d, g, squared = FALSE)

Arguments

d

A distance matrix object of class dist.

g

A factor representing the groups of items in d.

squared

If TRUE, return the squared distance to group centroids.

Details

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.

Value

A data frame with distances to the group centroids:

Item

A character vector of item labels from the dist object, or an integer vector of item locations if labels are not present.

CentroidGroup

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).

CentroidDistance

Inferred distance from the item to the centroid position of the indicated group.


usedist documentation built on March 2, 2020, 1:07 a.m.