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 y=freq/(#of stations in that time period)
. The following is a sample of my data set
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
Therefore I want
Var1 Var2 Var3 Freq
1 Floc July 11 P1 4/(21 - The number of samples taken in July).
Any ideas on how to write this code and then plot the results?