group_by function- dplyr

Hi, and welcome!

Please see the FAQ: What's a reproducible example (`reprex`) and how do I do one? Using a reprex, complete with representative data will attract quicker and more answers. It's not needed for this question because it uses the standard data set iris.

Also, please see the homework policy.

Here is a simple example of the workflow

suppressPackageStartupMessages(library(dplyr)) 
iris %>% group_by(Species) %>% summarize(sum(Sepal.Length))
#> # A tibble: 3 x 2
#>   Species    `sum(Sepal.Length)`
#>   <fct>                    <dbl>
#> 1 setosa                    250.
#> 2 versicolor                297.
#> 3 virginica                 329.

Created on 2020-03-25 by the reprex package (v0.3.0)

sum is a function that would be replaced with the appropriate functions for mean, etc.