title: Variance result differ in R language
body: <p>I have dataset with 61 entries.
  What i am trying to do is to calculate variance.</p>
  
  <p>I am doing it with two ways but they differ </p>
  
  <p>1st way is following </p>
  
  <p>$var X = E(X^{2}) - (EX)^{2}$</p>
  
  <p>so</p>
  
  <pre><code>&gt; c = 0
  
  &gt; for( year in females$Salary )
  +     c = c + (year^2)
  &gt; (c/length(females$Salary) - mean(females$Salary)^2
  [1] 286682.3
  </code></pre>
  
  <p>but when i use build in function</p>
  
  <pre><code>&gt; var(females$Salary)
  [1] 291460.3
  </code></pre>
  
  <p>as u can see the output is different. Why is this happening? Shouldnt they be the same?</p>