[R] Help rewriting looping structure?

2007-12-06 Thread TLowe
in 1:5) { tsum<- sum(tdat[,j]); for(k in 1:nrow(tdat)) { td<- tdat[k,j]; tmp<-tdat[,j]; # sum values <= to current value and divide by the total sum tdat[k,paste("cpct,j,sep="")]<- sum(tmp[tmp <= td]) / tsum; } } Thanks, TLowe -- Vi

Re: [R] Help rewriting looping structure?

2007-12-06 Thread TLowe
Thank you all. That's exactly what I was looking for. TLowe wrote: > > Hey Folks, > > Could somebody help me rewrite the following code? > > I am looping through all records across 5 fields to calculate the > cumulative > percentage of each record (rela

[R] Looping through a list of objects & do something...

2008-02-19 Thread TLowe
Hey Folks, Could somebody show me how to loop through a list of dataframes? I want to be able to generically access their elements and do something with them. For instance, instead of this: df1<- data.frame(x=(1:5),y=(1:5)); df2<- data.frame(x=(1:5),y=(1:5)); df3<- data.frame(x=(1:5),y=(1:5));