Al, Say, your data file is 'test', execute the following in sequence,
aggregate(test[1],test[2],mean)->inter names(inter)[2]='mean' merge(test,inter,all=T)->inter2 inter2$RSV=inter2$Result/inter2$mean The column 'RSV' in inter2 should be what you want. Jun On Tue, Mar 31, 2009 at 11:11 AM, Alan O'Loughlin <olo...@wyeth.com> wrote: > Thanks for replying, > > Actually I was trying to give a simple example of calculations just to see > the programming part of it. I'm actuually calculating the RSD% the 2 numbers > are replica standard devation results... Here is an example of my data set. > > > Result Index > 1 0.2901 17 > 2 0.2928 17 > 3 0.2913 18 > 4 0.2893 18 > 5 0.3526 9 > 6 0.3316 9 > 7 0.3492 10 > 8 0.3467 10 > 9 0.3385 11 > 10 0.3341 11 > 11 0.3449 12 > 12 0.3406 12 > 13 0.3690 13 > 14 0.3327 13 > 15 0.3324 14 > 16 0.3245 14 > 17 0.3245 15 > 18 0.3229 15 > 19 0.3331 16 > 20 0.3208 16 > Kind Regards, > Al > > >>> Jun Shen <jun.shen...@gmail.com> 31-Mar-09 17:08 >>> > Al, > > Is there any "ID" index for the pairs? For example, if the first pair can > be labeled "a", and second pair labeled "b" etc., then you can add an index > column or you may already have such a column in your list. Then run > aggregate(your.data.column, by=index.column, FUN=mean). Or you can just add > an extra index column anyway rep(1:number of the rows/2, each=2). Hope this > helps. > > -- > Jun Shen PhD > PK/PD Scientist > BioPharma Services > Millipore Corporation > 15 Research Park Dr. > St Charles, MO 63304 > Direct: 636-720-1589 > > On Tue, Mar 31, 2009 at 10:40 AM, Alan O'Loughlin <olo...@wyeth.com>wrote: > >> Hello, >> >> I'm trying to create a for loop for a data set, I have a list of results >> in this data set and I want to take the 1st two add them together and divide >> by the mean of the 1st to, then do the same for the 3rd and 4th values in >> the list and so on and each time return a value for the calculation on each >> pair. >> >> Any help would be appreciated. >> >> Thanks, >> Al >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > > > > > -- Jun Shen PhD PK/PD Scientist BioPharma Services Millipore Corporation 15 Research Park Dr. St Charles, MO 63304 Direct: 636-720-1589 [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.