title: converting equation into loop in r
body: <p>I',m new to coding, and I want to convert this equation in to loop in R, which gives a 20x20 matrix.</p>
  
  <p><a href="http://i.stack.imgur.com/N2HEN.jpg" rel="nofollow">the equation:</a></p>
  
  <p>I tried</p>
  
  <pre><code>for (i in 1:20) {
      for (j in 1:20) {
          ws[i,] = exp((-1*(SpectData[i,]-SpectData[j,])^2)/(2*sigma^2))
      } 
  }
  </code></pre>
  
  <p>but it didn't work , can any one help?</p>