changed usage of ddply to tapply for faster calcs on large data