I am trying to compute the fraction (%) of a each record from the group total in a dataframe. My data look like:
Where I have factors for Station, Month and PHylum and then a total. I would like to show the totals as relative %, so basically to sum the totals by Station and Month and then apply the original table.
In R, I got as far as:
bn_phyla %>% 
  group_by(Station, Month) %>% 
  summarise(total=sum(SumOfTotal Caught)) %>% 
  mutate(prop=SumOfTotal Caught/total)
Which gets me the group totals, but then how to I divide that back into the original data and preserve the Phylum column?
Thanks
PS..Does Stackoverflow have no way of inserting a table other than an image?

 
     
    