First start with Joran's excellent answer -- doubtful anything can better that.
Then the following mnemonics may help to remember the distinctions between each. Whilst some are obvious, others may be less so --- for these you'll find justification in Joran's discussions.
Mnemonics
lapply
is a list apply which acts on a list or vector and returns a list.sapply
is a simple lapply
(function defaults to returning a vector or matrix when possible)vapply
is a verified apply (allows the return object type to be prespecified)rapply
is a recursive apply for nested lists, i.e. lists within liststapply
is a tagged apply where the tags identify the subsetsapply
is generic: applies a function to a matrix's rows or columns (or, more generally, to dimensions of an array)Building the Right Background
If using the apply
family still feels a bit alien to you, then it might be that you're missing a key point of view.
These two articles can help. They provide the necessary background to motivate the functional programming techniques that are being provided by the apply
family of functions.
Users of Lisp will recognise the paradigm immediately. If you're not familiar with Lisp, once you get your head around FP, you'll have gained a powerful point of view for use in R -- and apply
will make a lot more sense.