As an example, this table snippet:
## AmAcid Codon Number PerThous
## 1 Gly GGG 25874 19.25
## 2 Gly GGA 13306 9.90
## 3 Ser UAC 25320 18.84
## 4 Ser UAU 68310 50.82
## 5 Val GUC 25874 19.25
## 6 Val GUA 13306 9.90
## 7 Gly GGT 25320 18.84
## 8 Gly GGC 68310 50.82
...
I want to write a function/loop that identifies all AmAcid == Gly
, then manipulate their respective values in Number
and/or PerThous
columns, such as finding the max, min, sum, etc. And repeats for every other unique string in AmAcid
, not just Gly
.
I have this very rough pseudocode, but I think I'm waaaay off base on R's syntax.
for (i in AmAcid_tabl$AmAcid) {
deviation$i <- (max(AmAcid_tabl$Number)-min(AmAcid_tabl$Number))/mean(AmAcid_tabl$Number)
}
How can I implement this properly?