I was reading through this blog post on R-bloggers and I'm confused by the last section of the code and can't figure it out.

<http://www.r-bloggers.com/self-organising-maps-for-customer-segmentation-using-r/>

I've attempted to recreate this with my own data. I have 5 variables that follow an exponential distribution with 2755 points.

I am fine with and can plot the map that it generates:

```
plot(som_model, type="codes")

```

![enter image description here](https://i.stack.imgur.com/tvAIy.png)

The section of the code I don't understand is the:

```
var <- 1
var_unscaled <- aggregate(as.numeric(training[,var]),by=list(som_model$unit.classif),FUN = mean, simplify=TRUE)[,2]
plot(som_model, type = "property", property=var_unscaled, main = names(training)[var], palette.name=coolBlueHotRed)

```

As I understand it, this section of the code is suppose to be plotting one of the variables over the map to see what it looks like but this is where I run into problems. When I run this section of the code I get the warning:

```
Warning message:
In bgcolors[!is.na(showcolors)] <- bgcol[showcolors[!is.na(showcolors)]] :
number of items to replace is not a multiple of replacement length

```

and it produces the plot:

![enter image description here](https://i.stack.imgur.com/Mj8at.png)

Which just some how doesn't look right...

Now what I think it has come down to is the way the aggregate function has re-ordered the data. The length of var\_unscaled is 789 and the length of som\_model$data, training[,var] and unit.classif are all of length 2755. I tried plotting the aggregated data, the result was no warning but an unintelligible graph (as expected).

Now I think it has done this because unit.classif has a lot of repeated numbers inside it and that's why it has reduced in size.

The question is, do I worry about the warning? Is it producing an accurate graph? What exactly is the "Property"'s section looking for in the plot command? Is there a different way I could "Aggregate" the data?