How to groupby values in R for the same value?

Take a look into group_by() and summarize() functions from dplyr package.

We could give you more specific help if you turn this into a reproducible example, if you never heard of it before, here is how to do it