title: How to compute summation in r
body: <p>My R code: </p>
  
  <pre><code>((x[1]-xm)^2)+((x[2]-xm)^2)+((x[3]-xm)^2)+((x[4]-xm)^2)+((x[5]-xm)^2)+((x[6]-xm)^2)
  </code></pre>
  
  <p>This computation would be much easier if i formulated the problem as a summation. How do I do that in r? Something like:</p>
  
  <pre><code>sum((x[i]-xm)^2) for i=1 to i=6?
  </code></pre>
  
  <p>x is a data frame.</p>