Reputation: 451
I'm running some code in R and I want to report computation time and results of the chunk of code I'm running. Since the computation take a while, I was wondering if there is a way to have as output (at the same time) the computing time and the results, without having to run the code twice (and therefore spending twice the time needed).
Upvotes: 1
Views: 81
Reputation: 459
Try something like this:
elapsed.time <- system.time(
results <- your.function()
)
print(elapsed.time)
print(results)
Upvotes: 6