ave and the "[" function in R

The ave function in R is one of those little helper function I feel I should be using more. Investigating its source code showed me another twist about R and the “[” function. But first let’s look at ave. The top of ave’s help page reads: Group Averages Over Level Combinations of Factors Subsets of x[] are averaged, where each subset consist of those observations with the same factor levels.