Think of the aggr () function as making a temporary table. For instance, let's say we have this real table of data: Customer, Value. A, 20. A, 30. B, 10. B, 15. C, 40. Now, as a nonsense requirement, let's say that we're looking for maximum value by customer, and then the minimum of THAT value across customers.