Learn R Programming

kohonen (version 3.0.10)

object.distances: Calculate distances between object vectors in a SOM

Description

This function calculates the distance between objects using the distance functions, weights and other attributes of a trained SOM. This function is used in the calculation of the U matrix in function plot.kohonen using the type = "dist.neighbours" argument.

Usage

object.distances(kohobj, type = c("data", "codes"), whatmap)

Arguments

kohobj

An object of class kohonen.

type

Whether to calculate distances between the data objects, or the codebook vectors.

whatmap

What data layers to use. If unspecified the data layers defined in the kohonen object are used.

Value

An object of class dist, which can be directly fed into (e.g.) a hierarchical clustering.

References

R. Wehrens and J. Kruisselbrink, submitted, 2017.

See Also

unit.distances, supersom

Examples

Run this code
# NOT RUN {
data(wines)
set.seed(7)
sommap <- supersom(list(measurements = scale(wines),
                        vintages = vintages),
                   grid = somgrid(6, 4, "hexagonal"))
obj.dists <- object.distances(sommap, type = "data")
code.dists <- object.distances(sommap, type = "codes")
# }

Run the code above in your browser using DataLab