How to re-label countries by continent and find the mean value

You have to use dplyr:group_by()

And dplyr::summarise()

If you need more specific help, please provide a proper REPRoducible EXample (reprex) illustrating your issue.