title: Mapping data to an SOM in R
body: <p>I am conducting a data analysis on some data in R. I discovered self-organizing maps (SOM) and it seems quite good to depict the link among the data. I tried both "kohonen" and "som" libraries. However, I am not able to map my data onto the created SOM. For instance, here is a picture I found in a SOM tutorial where the data (here, countries) are mapped onto the SOM.
  I can not figure out either how to extract information about the different nodes from a SOM object created by one of the two libraries listed above.</p>
  
  <p>Does someone know how to do it ?</p>
  
  <p><a href="https://i.stack.imgur.com/kcQIM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kcQIM.png" alt="enter image description here"></a></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Some data and code example (using the "kohonen" package):</p>
  
  <pre><code>library(kohonen)
  # wines = a dataset from kohonen library. It has 76 examples with 13 criteria.
  som_grid &lt;- somgrid(xdim=5, ydim=5, topo="hexagonal")
  som_model &lt;- som(wines, grid=som_grid)
  plot(som_model)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/IDUXu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IDUXu.png" alt="enter image description here"></a></p>
  
  <p>This code shows the number of items in each node of the SOM:</p>
  
  <pre><code>plot(som_model,type="counts",palette.name=coolBlueHotRed)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/2ItMh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2ItMh.png" alt="enter image description here"></a></p>
  
  <p>If we want to see the value of the first criteria for all nodes of the SOM:</p>
  
  <pre><code>var &lt;- 1
  var_unscaled &lt;- aggregate(as.numeric(wines[,var]),by=list(som_model$unit.classif),FUN=mean,simplify=TRUE)[,2]
  plot(som_model,type="property",property=var_unscaled,main=names(wines)[var])
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rrDA6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rrDA6.png" alt="enter image description here"></a></p>
  
  <p>I would like to create a map like the first image, meaning a SOM with the name of each variable mapped to the closest node of the SOM.</p>