title: calculating the outliers in R
body: <p>I have a data frame like this:</p>
  
  <p>x</p>
  
  <pre><code>Team 01/01/2012  01/02/2012  01/03/2012  01/01/2012 01/04/2012 SD Mean
  A     100         50           40        NA         30       60  80
  </code></pre>
  
  <p>I like to perform calculation on each cell to the mean and sd to calculate the outliers. For example,</p>
  
  <pre><code>abs(x-Mean) &gt; 3*SD
  </code></pre>
  
  <p><code>x$count&lt;-c(1)</code> (increment this value if the above condition is met).</p>
  
  <p>I am doing this to check the anomaly in my data set. If I know the column names, it would be easier to do the calculations, but number of columns will vary. Some cells may have NA in them. </p>
  
  <p>I like to subtrack mean from each cell, and I tried this</p>
  
  <pre><code>x$diff&lt;-sweep(x, 1, x$Mean, FUN='-')
  </code></pre>
  
  <p>does not seem to be working, any ideas?</p>