Sent from my phone. Please excuse my brevity.
On June 20, 2017 7:01:23 AM PDT, Wolfgang K <mails00000 at gmail.com> wrote:
>Hi,
>
>well, I know how to use for-loop and create vectors. That is not the
>point. However, implementing this code is - at least for me - not as
>trivial as it seems since you have changes in the signs as well as
>changes in multiplication by TPR1 and TPR2. I spent hours trying to
>get this peace of code sorted out but I just don't get it working. I
>managed to calculate the first two values L2 and L3 but no more. Since
>I am not advanced in R, I was asking for help with basic functions
>which I do know already.
>
>Yes I changed so much that I forgot to change res back to LSS.
>
>2017-06-20 15:46 GMT+02:00 Jeff Newmiller <jdnewmil at dcn.davis.ca.us>:
>> 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 <mails00000 at 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);
>>>
>>> }
>>>}