Re: [R] nested loop for

2011-07-22 Thread paloma ruiz benito
the groupwise sum in the output, use the following version instead: foo - function(d) { d - d[order(d$dbh2), ] d - transform(d, BAL2 = sum(SBA2) - cumsum(SBA2), aa = sum(SBA2)) d } HTH, Dennis On Thu, Jul 21, 2011 at 4:13 AM, paloma ruiz benito

[R] nested loop for

2011-07-21 Thread paloma ruiz benito
Hi everyone, I have been working some days in a nested loop in R but I can't find the solution. I have a data.frame with an unique ID for individuals and unique ID for different stands, for each indiviadual I have a dbh record and a SBA (stand basal area) field. Pma-rep (1:40) P-seq(1,4,