Re: [Rd] How to create arbitrary number of loops

2012-03-29 Thread Christian Brechbühler
On Wed, Mar 28, 2012 at 5:34 PM, Dai, Hongying, wrote: > Dear R users, > > I'm wondering how I can generate an arbitrary number of loops in R. > For instance, I can generate two "for" loops to get ICC among any two-way > combination among 10 variables. Here is the code > > n<-10 > for (i in 1:(n-

Re: [Rd] How to create arbitrary number of loops

2012-03-29 Thread Sarah Goslee
That sounds like a job for recursion. And also, a question for r-help and not r-devel. Sarah On Wed, Mar 28, 2012 at 5:34 PM, Dai, Hongying, wrote: > Dear R users, > > I'm wondering how I can generate an arbitrary number of loops in R. > For instance, I can generate two "for" loops to get ICC a

[Rd] How to create arbitrary number of loops

2012-03-29 Thread Dai, Hongying,
Dear R users, I'm wondering how I can generate an arbitrary number of loops in R. For instance, I can generate two "for" loops to get ICC among any two-way combination among 10 variables. Here is the code n<-10 for (i in 1:(n-1)) { for (j in (i+1):n) { icc(cbind(DATA[,i],DATA[,j])) } } If I need