title: R - add centroids to scatter plot
body: <p>I have a dataset two continuous variables and one factor variable (two classes). I want to create a scatterplot with two centroids (one for each class) that includes error bars in R. The centroids should be positioned at the mean values for x and y for each class.</p>
  
  <p>I can easily create the scatter plot using ggplot2, but I can't figure out how to add the centroids. Is it possible to do this using ggplot / qplot? </p>
  
  <p>Here is some example code:</p>
  
  <pre><code>x &lt;- c(1,2,3,4,5,2,3,5)
  y &lt;- c(10,11,14,5,7,9,8,5)
  class &lt;- c(1,1,1,0,0,1,0,0)
  df &lt;- data.frame(class, x, y)
  qplot(x,y, data=df, color=as.factor(class))
  </code></pre>