migue-s
3/27/2012 - 6:54 PM

R: Functions by ID

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.