Create a new parameter to group each subject and its activity, and use that to calculate the group mean with tapply function. Perfect version now