First of all your post seem to be asking two questions. The first one is: > I would like to know whether I can use an apply approach instead of aggregate. Is this going to speed up the process? You have shown the code you use and now you ask if doing something else is *going to speed up the process*. I'm not familiar with R but you and the community can only know by trying it out and see if this different approach speeds up a process. Instead you could have done that yourself, and then ask why your assumption about one way of solving has different characteristics than the other. Always be explicit about non-concrete indicators like *speed up*. Ask instead: > This solution runs in 1 minute 10 seconds for 1000 items. That needs to be less than 20 seconds. I tried the apply approach but that reduced it by 10 seconds. The second one is about subtracting stuff. Besides that I feel the question would be better asked separately as it's also missing any attempt from you so people visiting your question deemed it unclear where you were stuck. At least one visitor down voted your question, maybe for that reason. If you fix your question based on the suggestions presented here I'll consider using one of my re-open votes. Do note that [3 reviewers](http://stackoverflow.com/review/reopen/9451425) didn't feel the question was improved enough when they say it to cast a re-open vote. If I use my re-open vote your question still needs one other member to follow my vote.