Calculation by group in one column R : <pre><code>group=c("A","A","B","A","B","C","C","A")
y=c(3,4,5,2,1,4,1,2)
df=data.frame(group,y)
</code></pre>

<p>using <code>aggregate</code>, I can get the average by </p>

<pre><code>aggregate(df$y, list(df$group), mean)
</code></pre>

<p>But my question is: How to do something like : <code>(y_ij-mean_i)</code>
where <code>mean_i</code> is the average for group <code>i</code></p>

<p>thank you.</p>
