It will almost certainly be more elegant cody for you to use tidyverse to group by and summarise. As far as sharing representative data goes