Reputation: 109
I'm running Rstudio on a mac and my code slows down greatly when I place it between the brackets of a system.time command.
However system.time appears to report the actual time it takes to run the code without being placed in system.time(). Thus although it takes 2 or 3 minutes for the command to run within system.time(), it will report only a few seconds of elapsed time.
I'm not sure how to diagnose this behavior further.
One possible cause might be that I'm working with very large data tables and running efficient data.table commands that would take a long time to run in base r. Would this interfere with system.time()?
Upvotes: 1
Views: 285
Reputation: 1445
Try running it in the RGUI. One issue with RStudio (I have seen this same problem on my code) is that RStudio will want to update its Environment after each execution and this may take some time. I usually try to run large batch jobs in RGUI to avoid this issue.
Try it and report back.
Upvotes: 1