Error in !toroidal : invalid argument type in R wi

2019-07-27 22:14发布

问题:

I am trying to use som package in R and even though I am using the example data that comes with som package, it is still giving me an error. When i tried the same example dataset yesterday it worked. I am confused now..

Here is the code

library(som)
library(class)
data(wines)
set.seed(7)

training <- sample(nrow(wines), 120)
Xtraining <- scale(wines[training, ])
Xtest <- scale(wines[-training, ],
               center = attr(Xtraining, "scaled:center"),
               scale = attr(Xtraining, "scaled:scale"))

som.wines <- som(Xtraining, grid = somgrid(5, 5, "hexagonal"))

som.prediction <- predict(som.wines, newdata = Xtest,
                          trainX = Xtraining,
                          trainY = factor(wine.classes[training]))
table(wine.classes[-training], som.prediction$prediction)

The error I am getting is so generic and I am not been able to understand what exactly it is

som.wines <- som(Xtraining, grid = somgrid(5, 5, "hexagonal"))
Error in !toroidal : invalid argument type

回答1:

The code is working normally now on Rstudio. For some reason, it is not throwing the error anymore even though I haven't changed anything.



标签: r som