[R] Error
arun
smartpink111 at yahoo.com
Sat Aug 31 18:37:42 CEST 2013
Hi,
You forgot a closing parentheses ")".
x<-matrix(cells,nrow=7,ncol=2,byrow=TRUE,dimnames=list(rnames,cnames) #####
#run K-Means
km <-kmeans(x,4,10)
#Error: unexpected symbol in:
#"#run K-Means
#km"
x<-matrix(cells,nrow=7,ncol=2,byrow=TRUE,dimnames=list(rnames,cnames) )
km<-kmeans(x,4,10)
km$cluster
#A B C D E F G
#3 2 4 1 2 3 4
A.K.
Hi,
I am a new comer to R & I am trying to execute the below K-Means code:
cells <-c(1.1,60,8.2,20,4.2,35,1.5,21,7.6,15,2.0,55,3.9,39)
rnames <-c("A","B","C","D","E","F","G")
cnames <-c("X","Y")
x<-matrix(cells,nrow=7,ncol=2,byrow=TRUE,dimnames=list(rnames,cnames)
#run K-Means
km <-kmeans(x,4,10)
#print components of km
print(km)
#plot clusters
plot(x,col=km$cluster)
#plot centers
points(km$centers,col=1:2,pch=8)
I am getting the following error:
Error: unexpected symbol in:
"#run K-Means
km"
Please help me to eliminate this error.
PS: Error causing code is highlighted in above in bold.
More information about the R-help
mailing list