Skip to content
Prev 305716 / 398506 Next

help with calculation from dataframe with multiple entries per sample

On Sep 17, 2012, at 4:15 PM, Julie Lee-Yaw wrote:

            
Please tell me where you learned that as.data.frame(cbind(.)) construction.
mydata$gain2.3 <- with( mydata, ave( Mass , Time, FUN=function(x) diff(x[2],x[3]) ) )
Sample Time Mass gain2.3
1      1    1  3.0     0.3
2      1    2  3.1     0.3
3      1    3  3.4     0.3
4      2    1  4.0     0.1
5      2    2  4.3     0.1
6      2    3  4.4     0.1
7      3    1  3.0     0.3
8      3    2  3.2     0.3
9      3    3  3.5     0.3