I'd like to compute the mean by Mainland in each year.
The result would be something like:
Mainland 1990 1991 1992 1993 ...
Europe 1 55 66 678
Asia 43 6 7
Oceania .
Americas .
Africa .
Firstly, I selected the columns I need and then tried to do the calculation using the dplyr package in R but it doesnt work.
gr1 <- homicide_ratios %>%
select('Mainland', matches("[0-9]{4}"))
gr1 %>%
group_by(Mainland) %>%
summarise(media = mean(gr1[, 2:ncol(gr1)], na.rm = T))
I show you the dataset:
Thanks in advance.