Skip to main content
1 of 3
rene
  • 42.3k
  • 55
  • 610
  • 777

First of all your question 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 we can only know by trying it out if a different approach speeds up a process.

Instead you could have done that your self, and then ask why your assumption about one way of solving has different characteristics then the other.

Always be explicit about not concrete indicators like speed up. Ask instead:

This solution runs in 1 minute 10 seconds for 1000 items. That needs to be less then 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 that question better be asked separately it is 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 didn't feel the question was improved enough when they say it to cast a re-open vote. If I use mine re-open vote your question still needs one other member to follow my vote.

rene
  • 42.3k
  • 55
  • 610
  • 777