Skip to contents

Creates an interactive stopwatch in your R session. I recommend you don't call this function in your current R session, as it will block the console. You may consider running it from the command line in a new terminal window with

R -e "breaktime::stopwatch()"

Usage

stopwatch(
  target_time = NULL,
  start_color = NULL,
  end_color = NULL,
  sound = NULL,
  units = "minutes"
)

Arguments

target_time

[numeric(1)]
If target_time is not NULL, the stopwatch will change colors from start_color to end_color and play sound when target_time is reached. Defaults to NULL.

start_color, end_color

[character(1)]
Colors used to display the time. The time is displayed in start_color when there is time remaining, and in end_color when the timer has expired. Passed to cli::make_ansi_style(). Defaults to "green" and "red", respectively.

sound

[numeric(1)] or [character(1)] The sound played by beepr::beep() when a timer ends. See beepr::beep() for possible values.

If NULL, sound is disabled.

If a timer has expired and hasn't been ended, the sound will play again each time one-fifth of the target time passes (for example, if a session lasts 25 minutes, a reminder sound will play every 5 minutes after the session ends).

units

[character(1)]
Units used when interpreting numeric time period arguments. Defaults to "minutes". Accepted units are "seconds", "minutes", "hours", "days", "weeks", "fortnights", "months", "years", "decades", "centuries", or "millennia" (or abbreviations thereof).

Value

Invisibly returns an R6 object of class Stopwatch.