title: Ellipse containing percentage of given points in R
body: <p>I'm drawing F1/F2 vowel graph (<a href="http://coral.lili.uni-bielefeld.de/Courses/Summer04/HTHS/Salffner/f1f2.jpg" rel="noreferrer">an example is here</a>). Each vowel has several points/values, and I'd like to draw an ellipse around the points, so that:</p>
  
  <ul>
  <li>ellipse covers at least 80% of points (ie. in the picture above "i" has several values, but they are contained within the ellipse).</li>
  <li>is positioned in the direction on min/max values.</li>
  </ul>
  
  <p>I may be complicating the stuff, but trigonometry and maths are Greek to me. Below is what I've tried.</p>
  
  <p><strong>Ellipsoidhull()</strong></p>
  
  <p><a href="http://stat.ethz.ch/R-manual/R-devel/library/cluster/html/ellipsoidhull.html" rel="noreferrer">Ellipsoidhull()</a> is in the package package "cluster". If I pass to a function a matrix with F1 and F2, it seems to calculate the center of the ellipse, but the directional values are huge. For example:</p>
  
  <pre><code>&gt; olm
        ol.f1 ol.f2 # f1/f2 data
   [1,] 501.3 850.5
   [2,] 488.5 906.5
   [3,] 456.3 857.0
   [4,] 505.8 895.3
   [5,] 499.5 898.0
   [6,] 431.8 891.5
   [7,] 416.3 870.5
   [8,] 506.0 887.8
   [9,] 500.3 985.8
  [10,] 513.5 955.3
  [11,] 531.5 958.0
  [12,] 483.0 847.3
  [13,] 533.3 982.8
  [14,] 480.8 881.8
  [15,] 484.3 884.5
  </code></pre>
  
  <p>If passed to <code>ellipsoidhull</code>: </p>
  
  <pre><code>&gt; ellipsoidhull(olm)
  'ellipsoid' in 2 dimensions:
   center = ( 480.69 904.33 ); squared ave.radius d^2 =  2 
   and shape matrix =
         ol.f1  ol.f2
  ol.f1 2115.5 1449.5
  ol.f2 1449.5 3558.2
    hence, area  =  14636 
  </code></pre>
  
  <p>I guess it wouldn't be hard to figure out how to draw an ellipse, but the "shape matrix" (max/min radius values?) is too high. Btw, thanks to #R on Freednode for the tips. </p>
  
  <p><strong>Source code from EMU-R</strong></p>
  
  <p>Then, I've taken a look into the code of EMU-R, R package that works with <a href="http://emu.sourceforge.net/" rel="noreferrer">EMU</a> that can, amongst other things, draw F1/F2 with ellipsoids. The code that seems to do that is <a href="http://paste.pocoo.org/show/436320/" rel="noreferrer">here</a> but I don't understand how the ellipse is drawn.  </p>
  
  <p>Any help appreciated.</p>