Skip to content
Prev 305714 / 398506 Next

help with calculation from dataframe with multiple entries per sample

Julie -
    Since the apply functions operate on one row at a time, they
can't do what you want.  I think the easiest way to solve your 
problem is to reshape the data set, and merge it back with the 
original:
+                 Time=c(1,2,3,1,2,3,1,2,3),
+                 Mass=c(3,3.1,3.4,4,4.3,4.4,3,3.2,3.5))
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

You may want to avoid using special characters like dashes in variable
names.

Hope this helps.

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu
On Mon, 17 Sep 2012, Julie Lee-Yaw wrote: