A basic vignette on grids in SOMbrero

library("SOMbrero")

Definition and purpose of a myGrid class object

Objects of class myGrid are made to display the SOM grid.

Basic functions on a myGrid class object

In this section, we will consider only the four basic functions that can be applied on a myGrid class object:

The initGrid function

The initGrid function initializes a new myGrid object. It has 3 arguments:

The following R code initializes a new myGrid object of square topology, x dimension 5 and y dimension 6, and distance type maximum.

first_grid <- initGrid(dimension = c(5,6), topo = "square", dist.type = "maximum")

The print.myGrid function

The myGrid object print function prints the main features of the chosen object in the console. The only argument is the object to be printed.

Considering the previously initialized grid, the print command is:

print(first_grid)

The summary.myGrid function

The myGrid object summary function is quite simple. It only prints the class of the object and then calls the print function previously described. The only argument is the object to be summarized.

summary(first_grid)

The plot.myGrid function

The myGrid object plot function draws the squared area corresponding to the object, in a new graphical window. It has 3 parameters:

plot(first_grid)
plot(first_grid) + ggplot2::scale_fill_manual(values = rep("white", 30))
my_palette <- colorRampPalette(c("white", "pink", "purple"))(30)
plot(first_grid, show.names = FALSE) + 
  ggplot2::scale_fill_manual(values = my_palette)

Hexagonal grids can be displayed similarly:

second_grid <- initGrid(dimension = c(4, 5), topo = "hexagonal")
plot(second_grid, names = paste0("N", 1:20)) + 
  ggplot2::ggtitle("Hexagonal SOM grid")

Session information

This vignette has been computed with the following environment:

sessionInfo()


Try the SOMbrero package in your browser

Any scripts or data that you put into this service are public.

SOMbrero documentation built on Jan. 4, 2022, 1:07 a.m.