Complete tutorial on using 'apply' functions in R | R (for ecology)