Asked a similar question before and it was answered exceptionally in detail.
Grouping rows aggregate and function in r
My new grouping function is the pooled v