[R] translate formula into R code

Wolfgang K mails00000 at gmail.com
Tue Jun 20 09:44:13 CEST 2017


Hello,

I am trying to implement the following formula using for loops and vectors.
I am sure you can use some fancy R code to solve this but I would like to
keep it simple and stick to for and vector/array if that is possible.

TP = 200;
RL = 50;
TPR1 = TP - RL;
TPR2 = TP + RL;
PPO = 0;

LSS = 0.1;

counter = 1;

for(i in res) {

  # Even
  if(counter %% 2 == 1) {
    ls = abs((sum(LSS)* TP)) / (TPR1 - PPO);
    LSS = c(LSS,ls);

  }

  # Odd
  if(counter %% 2 == 0) {

    ls = abs((sum(LSS)* TPR2)) / (TP - PPO);
    LSS = c(LSS,ls);

  }
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Unbenannt.PNG
Type: image/png
Size: 146426 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20170620/29699747/attachment.png>


More information about the R-help mailing list