This is an excellent exercise for you, the beginner. If you explicitly want a line-by-line translation and don't want to use the strengths of R (vectorization/functions) then there isn't much point in asking us to read the Introduction to R document that comes with the software for you.
Please read the Posting Guide before posting again... your failure to switch your email client to plain text is going to lead to corruption of your question by the time w we see it eventually. PS you did not define what "res" is... -- Sent from my phone. Please excuse my brevity. On June 20, 2017 12:44:13 AM PDT, Wolfgang K <mails00...@gmail.com> wrote: >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); > > } >} ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.