I am trying to learn and implement spectral clustering on a multivariate dataset in R
. I have 9 independent variables and 1 dependent variable which is binary.
As a first step to spectral clustering, I am required to create a graph from the given data set (I have about 1000 observations). Because I am just starting out, I don't really care about the method used to create the graph but it will be better if it uses k-nearest neighbors.
I came across a function nng
in the package cccd
which creates the graph.
I used the following:
knnGraph<-nng(as.matrix(data[2:10]),k=3)
This runs fine, except that when I try to visualize the graph by using plot(knnGraph)
, I get the following error:
Error in layout.norm(layout, -1, 1, -1, 1) :
`layout' should have 2 or three columns
I am not sure how to proceed, any help would be much appreciated. I also tried to find a step-by-step tutorial to implement spectral clustering in R, but was unable to find it. Any pointers to any such resource will be much appreciated as well.