unit.distances: Function to calculate distances between units in a SOM

Description Usage Arguments Value Author(s) See Also Examples

View source: R/wccsom.R

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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)

wccsom documentation built on May 30, 2017, 12:52 a.m.