unit.distances {wccsom}R Documentation

Function to calculate distances between units in a SOM

Description

Function calculates Euclidean distances between units in a SOM; if argument '"toroidal"' is TRUE, the edges of the map are considered to be joined so that the overal shape of the map is a torus. The distances are calculated correspondingly.

Usage

unit.distances(grid, toroidal)

Arguments

grid A somgrid object.
toroidal For toroidal maps, equal to TRUE. Default is FALSE.

Value

Returns a distance matrix.

Author(s)

Ron Wehrens

See Also

wccsom, wccxyf

Examples

gr <- somgrid(3, 3, "hexagonal")
x <- list(grid = gr)
class(x) <- "wccsom" 

par(mfrow = c(1,2))
unit.dists <- unit.distances(gr, toroidal = FALSE)
plot(x, type = "property", property = unit.dists[1,],
     main = "Distances to unit 1", zlim = c(0,2.75), contin = TRUE)
unit.dists <- unit.distances(gr, toroidal = TRUE)
plot(x, type = "property", property = unit.dists[1,],
     main = "Toroidal distances to unit 1", zlim = c(0,2.75), contin = TRUE)

[Package wccsom version 1.2.3 Index]