[R] help with double looping

Rui Barradas ruipbarradas at sapo.pt
Fri Feb 8 17:37:52 CET 2013


Hello,

Maybe seq(1, 16*11, 11)? (16*11 is 176, not 166)


Hope this helps,

Rui Barradas

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
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list