data(wines)
set.seed(7)
training <- sample(nrow(wines), 120)
Xtraining <- scale(wines[training, ])
somnet <- som(Xtraining, somgrid(5, 5, "hexagonal"))
mapping <- map(somnet,
scale(wines[-training, ],
center=attr(Xtraining, "scaled:center"),
scale=attr(Xtraining, "scaled:scale")))
Run the code above in your browser using DataLab