I'm trying to run some and k means analysis. But I can't solve it because there's an error code.
Error in storage.mode(x) <- "double" : 'list' object cannot be coerced to type 'double'
library(kohonen)
cdata <- read.delim("Cluster.txt", stringsAsFactors=FALSE)
cdata.n <- scale(subset(cdata, select=-c(ID)))
som_model2 <- supersom(data = cdata.n, grid = somgrid(10, 10, "rectangular"))
k = 6
somClusters <- kmeans(som_model2$codes, centers = 6)
I was advised to use the "unlist", and its result is as follow.
Cluster means:
[,1]
1 -0.6702128
2 5.2157179
3 1.2555768
4 -0.2632253
5 2.6067733
6 0.3503127
But the results of the example are as follows.
## Cluster means:
## MONEY VISIT CROSS API
## 1 8.2237320 4.8942046 3.6120212 -0.8606384
## 2 -0.2699493 -0.3223770 -0.3357094 -0.2496793
## 3 0.3566740 0.5408914 0.9180064 -0.6252556
## 4 -0.4596952 -0.6586599 -0.9624127 4.2828612
## 5 2.0625665 2.6264913 2.0452184 -0.7848548
## 6 -0.4199132 -0.5746073 -0.7785007 1.1355674
How can I get this result?
I use this data: