SOMbrero
Objects of class myGrid are made to depict a grid. To be able to create such
objects, you have to load the package SOMbrero
.
In this section, we will consider only the four basic functions that can be applied on myGrid class object:
The initGrid function initializes a new myGrid object. It has 3 parameters:
dimension
, which is vector of two integers. The first one is the x
dimension, the second one is the y dimension. The default dimensions are
x=5 and y=5,topo
, which is the topology choosen. The value of this argument must be
one of these: square
. Thedefault value is square.dist.type
, which is the distance type. The default value is
maximum.The following R code initializes a new myGrid object of square topology, x dimension 5 and y dimension 6.
my.first.grid <- initGrid(dimension = c(5, 6), topo = "square", dist.type = "maximum")
The myGrid object print function prints in the console the main features of the choosen object. The only argument is the object to be printed.
Considering the previously initialized grid, the print command is:
print(my.first.grid)
##
## Self-Organizing Map structure
##
## Features :
## topology : square
## x dimension : 5
## y dimension : 6
## distance type: maximum
The myGrid object summary function is quite simple. It only prints the class of the object and then call the function print previously described. The only argument is the object to be summarized.
summary(my.first.grid)
##
## Summary
##
## Class : myGrid
##
## Self-Organizing Map structure
##
## Features :
## topology : square
## x dimension : 5
## y dimension : 6
## distance type: maximum
The myGrid object plot function draws, in a new graphical window, the squared area corresponding to the object. It has 2 parameters:
# plot without any color specification: squares are filled in white color
plot(my.first.grid)
# generating colors from the rainbow() function
my.colors <- rainbow(5 * 6)
plot(my.first.grid, neuron.col = my.colors)