R: Functions by ID
If we wanted to create a new column containing the sum of a variable by ID: theDataframe <- ddply(theDataframe, .(ID), transform, newVariable = sum(theVariable)) , we can also use this aproach to count, min, max, mean, etc.