Skip to content

Instantly share code, notes, and snippets.

@ottadini
Created November 29, 2013 00:07
Show Gist options
  • Save ottadini/7699770 to your computer and use it in GitHub Desktop.
Save ottadini/7699770 to your computer and use it in GitHub Desktop.
Means to create a coloured hexagonal "heat map" plot of SOM map from kohonen package.
# I cannot remember the source for this code. It isn't mine. Probably somewhere on stackoverflow.
require ("kohonen")
require ("latticeExtra")
require ("deldir")
data(wines)
som.wines <- som (scale (wines), grid = somgrid(5, 5, "hexagonal"))
df <- as.data.frame (cbind (som.wines$grid$pts, som.wines$codes))
levelplot (alcohol ~ x * y, data = df, panel = panel.voronoi, aspect = "iso")