Re: [R] Looping through rows of all elements of a list that has variable length

2013-02-04 Thread Dimitri Liakhovitski
Thanks a lot, Pratap! Dimitri On Mon, Feb 4, 2013 at 9:43 AM, nalluri pratap wrote: > Just modified your code a bit, hope this helps: > > a=expand.grid(1:2,1:2) > b=expand.grid(1:2,1:2,1:2) > c=expand.grid(1:2,1:2,1:2,1:2) > l.long<-list(a,b,c) > mygrid<-do.call(expand.grid,lapply(l.long,funct

Re: [R] Looping through rows of all elements of a list that has variable length

2013-02-04 Thread nalluri pratap
Just modified your code a bit, hope this helps:   a=expand.grid(1:2,1:2) b=expand.grid(1:2,1:2,1:2) c=expand.grid(1:2,1:2,1:2,1:2) l.long<-list(a,b,c) mygrid<-do.call(expand.grid,lapply(l.long,function(x) 1:nrow(x))) out<-vector("list",nrow(mygrid)) for(gridrow in 1:nrow(mygrid)) {   sum_rows=0