I have a dataframe df with my data of interest
I rescale with
df.sc <- scale(df)
and make my Kohonen map with
df.grid <- somgrid(15, 10, "hexagonal")
df.som <- som(df.sc, rlen=700, grid = df.grid)
That works fine and I get a nice map.
Now I have an extra datapoint
extra.sc <- as.matrix(-0.29985191, -0.35905786, -0.260923297, -0.2415673150,
-0.259426676, -0.330404078)
It is scaled exactly the same way as df.sc
Now I want to see the position of the unit in the kohonen map given the df.som for the extra.sc
map(df.som,extra.sc)
does not give me what I want.
How can I determine the position of extra.sc within df.som? And preferentially also how I can mark it on the map
Maybe you defined your new data incorrectly, i.e. they did not have similar dimension with that of the training data. Check the output of
extra.sc
using parenthesis(extra.sc)
. I recommend that you provide the number of rows and columns to the definition ofextra.sc
usingmatrix()
andc()
function instead ofas.matrix()
. For example:and observe the result:
(extra.sc)
It is one row and six columns. If you do not provide the shape of your data, then R will regard them as one column and six rows.