[R] help with double looping

Fri Feb 8 18:54:15 CET 2013

```Hello,

You're right, sorry for the misleading tip. How about seq(1, 177, 11)?
Please note that without a data example, it's not very easy to say.
Can't you post a small dataset using ?dput

dput(head(data, 20))  # paste the output of this.

Em 08-02-2013 17:10, christel lacaze escreveu:
>
> that doesn't seem to be the issue i'm afraid... both j sequences produce the same numbers:
>
>> j<-seq(1,166,11)
>> j
>   [1]   1  12  23  34  45  56  67  78  89 100 111 122 133 144 155 166
>> j<-seq(1,176,11)
>> j
>   [1]   1  12  23  34  45  56  67  78  89 100 111 122 133 144 155 166
>
>> Date: Fri, 8 Feb 2013 16:37:52 +0000
>> To: christellacaze at hotmail.co.uk
>> CC: r-help at r-project.org
>> Subject: Re: [R] help with double looping
>>
>> Hello,
>>
>> Maybe seq(1, 16*11, 11)? (16*11 is 176, not 166)
>>
>>
>> Hope this helps,
>>
>>
>> Em 08-02-2013 16:03, christel lacaze escreveu:
>>>
>>> hi there,
>>>
>>> I have a dataframe in the shape vA1, vA2,..., vA11, vB1, vB2,..., VB11,......., VP1, VP2,...., VP11 (so 16 times a sequence of 11 variables)
>>> I am trying to build a double loop so that i can apply the function (i-1)*v(i) to the first 10 variables, then the same for the next 10 variables, etc... 16 times.
>>>
>>> I have tried the following with no luck:
>>>
>>> iscores<-list()
>>> for (j in seq(1,166,11))
>>>     {
>>>     for (i in j:(j+10))
>>>       {iscores[[i-j+1]]=(i-j)*data[[i-j+1]]
>>>       }
>>>     }
>>>
>>> any suggestion...?
>>>
>>> many thanks,
>>>
>>> Christel
>>>
>>> 	[[alternative HTML version deleted]]
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help