Comparing tapply( ), for( ) and aggregate( ) functions in R