Learn R Programming

kohonen (version 1.1.1)

unit.distances: Calculate distances between units in a SOM

Description

Calculate distances between units in a SOM.

Usage

unit.distances(grid, toroidal)

Arguments

grid
an object of class somgrid.
toroidal
if true, edges of the map are joined so that the topology is that of a torus.

Value

  • Returns a matrix containing distances.

Examples

Run this code
library(kohonen)
data(wines)

kohmap <- som(wines, grid = somgrid(5, 5, "hexagonal"), rlen=100)

par(mfrow=c(1,2))
dists <- unit.distances(kohmap$grid, toroidal=FALSE)
plot(kohmap, type="property", property=dists[1,],
     main="Distances to unit 1", zlim=c(0,4))
dists <- unit.distances(kohmap$grid, toroidal=TRUE)
plot(kohmap, type="property", property=dists[1,],
     main="Distances to unit 1 (toroidal)", zlim=c(0,4))

Run the code above in your browser using DataLab