Entering edit mode
Xiao Shi
▴
90
@xiao-shi-1184
Last seen 10.2 years ago
Hi every,
When i use MSS in the HOPACH package ,but the R teminated to the shell
command line.My script is as follows:
###==============
library(som)
library(EMV)
library(hopach)
## Read data file
zheng=read.table(file="/home/jtshi/R/zheng.txt",header=TRUE,row.names=
1)
zheng.m=as.matrix(zheng)
## Use knn in the EMV package to estimate the missing value
zheng.knn=knn(zheng.m)
a=zheng.knn[[1]]
## Caculate the distancematrix for HOPACH
zheng.dist<-distancematrix(a,d="euclid")
zheng.mss=array(c(0),dim=c(10,10))
## Then a loop to caculate th MSS value with different SOM cluster
number
for(i in 2:10){
for(j in 2:10){
zheng.som<-som(a, xdim=i, ydim=j)
zheng.visual=zheng.som$visual[,1:2]
lable=zheng.visual[,1]+zheng.visual[,2]*i+1
zheng.mss[i,j]=labelstomss(lable,zheng.dist,hierarchical=FALSE)
}
}
## But the R teminated to shell command line with the following waring
message
## R: tnt/vec.h:250: T& TNT::Vector<t>::operator()(TNT::Subscript)
[with T =
## double ]: Assertion `i <= n_' failed.
## The same thing happens when i try this code on windows.
## Then i try a single run with a set i and j
i=7
j=8
zheng.som<-som(a, xdim=i, ydim=j)
zheng.visual=zheng.som$visual[,1:2]
lable=zheng.visual[,1]+zheng.visual[,2]*i+1
zheng.mss[i,j]=labelstomss(lable,zheng.dist,hierarchical=FALSE)
zheng.mss[i,j]
[1] 0.3747688
## So what's wrong with the loop? Any suggestions ?The data file is
attached.
## Thanks.
[[alternative HTML version deleted]]