title: R: Robust fitting of data points to a Gaussian function
body: <p>I need to do some robust data-fitting operation.</p>
  
  <p>I have bunch of (x,y) data, that I want to fit to a <a href="http://en.wikipedia.org/wiki/Gaussian_function" rel="nofollow noreferrer">Gaussian</a> (aka normal) function. 
  The point is, I want to remove the ouliers. As one can see on the sample plot below, there is another distribution of data thats pollutting my data on the right, and I don't want to take it into account to do the fitting (i.e. to find \sigma, \mu and the overall scale parameter).
  <img src="https://i.stack.imgur.com/58yg4.png" alt="sample data plot"></p>
  
  <p>R seems to be the right tool for the job, I found some packages (<a href="http://cran.r-project.org/web/packages/robust/" rel="nofollow noreferrer">robust</a>, <a href="http://cran.r-project.org/web/packages/robustbase/" rel="nofollow noreferrer">robustbase</a>, <a href="http://cran.r-project.org/web/packages/MASS/" rel="nofollow noreferrer">MASS</a> for example) that are related to robust fitting.</p>
  
  <p>However, they assume the user already has a strong knowledge of R, which is not my case, and the documentation is only provided as a sort of reference manual, no tutorial or equivalent. My statistical background is rather low, I attempted to read <a href="http://cran.r-project.org/doc/contrib/Ricci-distributions-en.pdf" rel="nofollow noreferrer">reference material on fitting with R</a>, but it didn't really help (and I'm not even sure thats the right way to go).
  But I have the feeling that this is actually a quite simple operation.</p>
  
  <p>I have checked this <a href="https://stackoverflow.com/questions/14511454/">related question</a> (and the linked ones), however they take as input a single vector of values, and I have a vector of pairs, so I don't see how to transpose.</p>
  
  <p>Any help on how to do this would be appreciated.</p>