```{r=Creating SOMs in R}
#Install the kohonen package
install.packages("kohonen")
#load the kohonen package
library(kohonen)
# Create a training data set (rows are samples, columns are variables)
setwd("D:\\workingdirectory")
data_train<-read.csv("CD44.csv")
# Change the data frame with training data to a matrix
# Also center and scale all variables to give them equal importance during
# the SOM training process.
row.names<-data_train[,1]
data_train_matrix <- as.matrix(scale(data_train[,-1]))
# Create the SOM Grid - you generally have to specify the size of the
# training grid prior to training the SOM. Hexagonal and Circular
# topologies are possible
som_grid <- somgrid(xdim = 7, ydim=30, topo="hexagonal")
# Finally, train the SOM, options for the number of iterations,
# the learning rates, and the neighbourhood are available
som_model <- som(data_train_matrix,
grid=som_grid,
rlen=100,
alpha=c(0.05,0.01),
keep.data = TRUE,
n.hood="circular")
```
最后一步的结果是
Error in sample.int(length(x), size, replace, prob) : cannot take a sample larger than the population when 'replace = FALSE'请教高手,这是什么原因?