title: Error: ggplot2 doesn't know how to deal with data of class matrix?
body: <p>How can I make <code>ggplot</code> work with this data I tried normal plotting and it works just fine, but I want better visualization when I use <code>ggplot</code>, it gives me the above error, How do I fix this ?</p>
  
  <p>This is an implementation of spectral clustering algorithm. and the code works well and the data is classified correctly. I just need to show this now .</p>
  
  <pre><code>library(ggplot2)
  
  input_data &lt;- as.matrix(read.table("SpectData.txt"))
  colnames(input_data) &lt;- c("x1", "x2")
  
  #1- Define Weights matrix
  W &lt;- matrix(0,nrow = nrow(input_data),ncol = nrow(input_data))
  
  #2- Define Degree Matrix
  D &lt;- matrix(0,nrow = nrow(input_data),ncol = nrow(input_data))
  
  calculateWeight &lt;- function(x1,x2,sigma) {
    result &lt;- exp(- (norm(x2-x1,type = "2"))^2/ (2*sigma^2))
    result
  }
  
  calcWieghtMatrix &lt;- function(sigma) {
    for(i in 1: nrow(W)){
     for(j in 1: nrow(W)){
      if(i == j){
        next
      }
      if( W[i,j] != 0){
        next
      }
  
      W[i,j] &lt;&lt;- calculateWeight(input_data[i,],input_data[j,],sigma)
      W[j,i] &lt;&lt;- W[i,j]
    }
   }
  }    
  
  calcDegreeMatrix &lt;- function()  {
    for( i in 1:nrow(input_data)){
      D[i,i] &lt;&lt;- sum(W[i,])
    }
  }
  
  executeSpectralClustring &lt;- function (sigma,numberOfClusters){
    calcWieghtMatrix(sigma)
    calcDegreeMatrix()
    L &lt;&lt;- D - W
    eigenDecompostion &lt;- eigen(L,symmetric = FALSE)
    index &lt;- ncol(eigenDecompostion$vectors)-1
    eigenVector &lt;- eigenDecompostion$vectors[,index] 
    cl &lt;- kmeans(eigenVector,numberOfClusters)
    ggplot(input_data,col = cl$cluster)
  }    
  
  executeSpectralClustring(0.01,2)
  </code></pre>