knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
An R package implementing a simple timer as an R6 class.
The timer has four functions: $start()
, $stop()
, $reset()
and $elapsed()
.
The $elapsed()
function returns the elapsed wall clock time (as opposed to CPU time)
as an object of class lubridate::Duration
.
library(timer) # instantiate a new timer timer <- Timer$new() # no time has elapsed because the timer has not started timer$elapsed() # start the timer timer$start() # get the time elapsed (as an object of class lubridate::Duration) # time elapsed is increasing because the timer is still running timer$elapsed() timer$elapsed() # stop the timer timer$stop() # time elapsed is now fixed timer$elapsed() timer$elapsed() # because timer is an object of class R6 use the clone() function # to make a copy timer2 <- timer$clone() # reset the timer timer$reset() timer$elapsed() # timer2 is not reset timer2$elapsed()
To install from GitHub
# install.packages("devtools") devtools::install_github("poissonconsulting/timer")
Please report any issues.
Pull requests are always welcome.
Please note that the timer project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.