Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a problem which i'm finding tricky to solve . I have a data frame that looks like this :
Date	treatment	AVG("one.Other.Other.Other.Other.Other")	avg("k__Bacteria.p__Actinobacteria.c__Actinobacteria.o__Actinomycetales.f__Actinomycetaceae.g__Actinomyces")	avg("k__Bacteria.p__Actinobacteria.c__Actinobacteria.o__Bifidobacteriales.f__Bifidobacteriaceae.g__Bifidobacterium")
25.7.2021	Original Sample	0	5.28E-05	0.08379538
29.7.2021	Treatment 1	0	0	0.38547496
29.7.2021	Treatment 10	0	0	0.589164539
29.7.2021	Treatment 2	0	0	0.282869579
29.7.2021	Treatment 3	0	0	0.251450878
29.7.2021	Treatment 4	0	0	0.736359499
29.7.2021	Treatment 5	0	0	0.305756115
29.7.2021	Treatment 6	0	0	0.281702441
29.7.2021	Treatment 7	0	0	0.491254245
29.7.2021	Treatment 8	0	0	0.325992622
29.7.2021	Treatment 9	0	0	0.434048894

It has 89 columns. What I wish to do is create a new data frame which will contain all the columns and the observation values will be for any column : (treatment 1 of column x/original sample of column x) (treatment 2 of column x/original sample of column x) and so on for all the 10 treatments and doing this calculations for all columns

I thought about doing nested for loops but is doesn't seem to work.

What I have tried:

data_slope=for(i in 3:ncol(data_work_final)) {       
  for(j in length(data_work_final[i]) {
    data_slope$data_work_final[i[j]]=data_work_final[i[j]]/data_work_final[data_work_final[i[1]]
    
  }
}
Posted
Updated 28-Nov-21 22:16pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900