Or use group_by
& summarise_at
from the dplyr
package:
library(dplyr)
d %>%
group_by(Name) %>%
summarise_at(vars(-Month), funs(mean(., na.rm=TRUE)))
# A tibble: 3 x 3
Name Rate1 Rate2
<fct> <dbl> <dbl>
1 Aira 16.3 47.0
2 Ben 31.3 50.3
3 Cat 44.7 54.0
See ?summarise_at
for the many ways to specify the variables to act on. Here, vars(-Month)
says all variables except Month
.