Error in supersom(list(X), …) : argument “X” is missing, with no default in kohonen package som function

你说的曾经没有我的故事 提交于 2020-03-25 12:32:10

问题


I am trying to apply the som function in the kohonen package (plot a SOM) and I am getting the following error:

Error in supersom(list(X), ...) : argument "X" is missing, with no default.

The code that I am trying to apply is as follows:

...

load("somInput.rdata")

...

aGrid <- somgrid(xdim = 160, ydim = 100, topo="hexagonal")
data <- as.matrix(scale(na.omit(usa.bg.som[,1:7])))
aSom <- som(data=data, grid=aGrid, rlen=1, alpha=c(0.05, 0.01), keep.data=FALSE)

After the last line above I get the error.

Can anyone resolve the error? Help is revered.

The full code:

##CODE FOR BRUNDSON AND SINGLETON BOOK CHAPTER.



##LIBRARIES

library(kohonen)



##Code for Plots

source("somComponentPlanePlottingFunction.R")

#source("Map_COUNTY_BMU.R")

source("plotUMatrix.R")





#Load Data

##DATA FOR ALL BLOCKGROUPS IN THE US

##SOURCE ACS 2006-2010 AND CENSUS 2010

load("somInput.rdata")



#Build SOM

aGrid <- somgrid(xdim = 160, ydim = 100, topo="hexagonal")



##NEXT LINE IS SLOW!!!

##Rlen is arbitrarily low

data <- as.matrix(scale(na.omit(usa.bg.som[,1:7])))

aSom <- som(data=data, grid=aGrid, rlen=1, alpha=c(0.05, 0.01), keep.data=FALSE)



##VISUALIZE RESULTS

##COMPONENT PLANES

dev.off()

par(mar = rep(1, 4))

cplanelay <- layout(matrix(1:8, nrow=4))

vars <- colnames(aSom$data[[1]])

for(p in vars) {

  plotCplane(som_obj=aSom, variable=p, legend=FALSE, type="Quantile")

}

plot(0, 0, type = "n", axes = FALSE, xlim=c(0, 1), 

     ylim=c(0, 1), xlab="", ylab= "")

par(mar = c(0, 0, 0, 6))

image.plot(legend.only=TRUE, col=rev(designer.colors(n=50, col=brewer.pal(9, "Spectral"))), zlim=c(-1.5,1.5))

##END PLOT



##PLOT U-MATRIX

dev.off()

plotUmat(aSom)

The full code can be retrieved from:

https://github.com/geoss/som_visualization_r/blob/master/Example.R

Other needed files can be viewed and retrieved from:

https://github.com/geoss/som_visualization_r

A question about how to plot hexagongrid in SOM in R:

R package Kohonen - how to plot hexagons instead of circles as in Matlab SOM toolbox?

来源:https://stackoverflow.com/questions/60757051/error-in-supersomlistx-argument-x-is-missing-with-no-default-in-ko

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!