That seems to work. I should add that to make "ave" work like "by" one can do:
mydata$newvar <- ave(1:nrow(mydata), mydata$some_factor, FUN= function (x) { x <- ds[x,] # ... etc... }) Thanks! David [[alternative HTML version deleted]] ______________________________________________ R-help@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.