Skip to content
Prev 377575 / 398502 Next

Applying a certain formula to a repeated sample data

Dear Jim,

I don't think my problem is clear the way I put.

I have been trying to manually apply the formula to some rows.

This is what I have done.
I cut and past some rows from 1-7 and save each with a different file as
shown below:

1 8590 12516
2 8641 98143
3 8705 98916
4 8750 89911
5 8685 104835
6 8629 121963
7 8676 77655


1 8577 81081
2 8593 83385
3 8642 112164
4 8708 103684
5 8622 83982
6 8593 75944
7 8600 97036


1 8650 104911
2 8730 114098
3 8731 99421
4 8715 85707
5 8717 81273
6 8739 106462
7 8684 110635


1 8713 105214
2 8771 92456
3 8759 109270
4 8762 99150
5 8730 77306
6 8780 86324
7 8804 90214


1 8797 99894
2 8863 95177
3 8873 95910
4 8827 108511
5 8806 115636
6 8869 85542
7 8854 111018


1 8571 93247
2 8533 85105
3 8553 114725
4 8561 122195
5 8532 100945
6 8560 108552
7 8634 108707


1 8646 117420
2 8633 113823
3 8680 82763
4 8765 121072
5 8756 89835
6 8750 104578
7 8790 88429

Each of them are then read as:
d1<-read.table("dat1",col.names=c("n","CR","WW"))
d2<-read.table("dat2",col.names=c("n","CR","WW"))
d3<-read.table("dat3",col.names=c("n","CR","WW"))
d4<-read.table("dat4",col.names=c("n","CR","WW"))
d5<-read.table("dat5",col.names=c("n","CR","WW"))
d6<-read.table("dat6",col.names=c("n","CR","WW"))
d7<-read.table("dat7",col.names=c("n","CR","WW"))

And my formula for percentage change applied as follows for column 2:
a1<-((d1$CR-mean(d1$CR))/mean(CR))*100
a2<-((d2$CR-mean(d2$CR))/mean(CR))*100
a3<-((d3$CR-mean(d3$CR))/mean(CR))*100
a4<-((d4$CR-mean(d4$CR))/mean(CR))*100
a5<-((d5$CR-mean(d5$CR))/mean(CR))*100
a6<-((d6$CR-mean(d6$CR))/mean(CR))*100
a7<-((d7$CR-mean(d7$CR))/mean(CR))*100

a1-a7 actually gives percentage change in the data.

Instead of doing this one after the other, can you please give an
indication on how I may apply this formula to the data frame with probably
a code.

Thank you again.

Best
Ogbos

On Wed, Nov 28, 2018 at 5:15 AM Ogbos Okike <giftedlife2014 at gmail.com>
wrote: