If you want to display time elapsed nicely in an Rmd object generated by knitr, here is my suggesion:
t1 <- Sys.time()
Sys.sleep(5)
t2 <- Sys.time()
tDiff <- difftime(t2, t1, units = "hours")
This process took 0.00139 hours
. Note that units above can be whatever unit you want, see ?difftime.