old <- Sys.time()
// MY code
new <- Sys.time()
total time = old-new the output comes "Time difference of -6.661923 secs"
instead i want "Execution time : 0.35secs"
You can use sprintf as below:
old <- Sys.time()
rnorm(500,0,1)
new <- Sys.time()
x <- (new - old)
sprintf("The execution time is %5.2f secs",x)
Output:
[1] "The execution time is 1.08 secs"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With