Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A countdown timer in the R console (beware: it clears the console first)
# See Colin Fay's tweet
# https://twitter.com/_ColinFay/status/1465253187284254724
countdown <- function(s) {
cat("\014") # clear console
for (i in rev(seq(s))) {
cat("Countdown:", i, "s\n")
Sys.sleep(1)
cat("\014")
}
cat(paste0("Countdown complete (", s, " seconds)"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment