title: Writing command in R to remove outliers in residual plot
body: <p>I want to delete outliers  (defined as more than 2 standard deviations from the mean) in the residual plots ?</p>
  
  <p>what command should I write?</p>
  
  <pre><code>DF.mod.2&lt;- lm(X ~ A+ B+ C+ D+ F, data=DF)
  </code></pre>
  
  <p>I got the mean of residuals by this command: </p>
  
  <pre><code>mean(resid(DF.mod.2))
  </code></pre>
  
  <p>and standard deviation by this command: </p>
  
  <pre><code>sqrt(deviance(DF.mod.2)/df.residual(DF.mod.2))
  </code></pre>
  
  <p>Then how could I exclude the residuals (which have distance more than 2 standard deviations from the mean) from my data frame?</p>
  
  <p>the residual plots:</p>
  
  <p><img src="https://i.stack.imgur.com/tX0rN.jpg" alt="enter image description here"></p>
  
  <p>Please help me... I am working on these data for one week and I do not know how to remove outliers! I am allowed to remove 200 outliers (not more).</p>