title: Divide Groups by # of samples in each group in R
body: <p>I'm trying to use ggplot to make a graph that has the composition of substrates at 6 different sites and at 7 different times. The problem is I have different amount of samples for each sampling period and site. I essentially want the code <code>y=freq/(#of stations in that time period)</code>. The following is a sample of my data set </p>
  
  <pre><code>   Substrate     Time   Site Freq
  1      Floc    July 11   P1    4
  2      Fine    July 11   P1    2
  3    Medium    July 11   P1   12
  4    Coarse    July 11   P1    0
  5   Bedrock    July 11   P1    3
  6      Floc     Aug 11   P1    7
  7      Fine     Aug 11   P1    1
  8    Medium     Aug 11   P1    7
  9    Coarse     Aug 11   P1    1
  10  Bedrock     Aug 11   P1    4
  </code></pre>
  
  <p>Therefore I want </p>
  
  <pre><code>      Var1       Var2 Var3 Freq
  1      Floc    July 11   P1    4/(21 - The number of samples taken in July).
  </code></pre>
  
  <p>Any ideas on how to write this code and then plot the results?</p>