Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FTW
a <- 1
b <- 2
ftw <- function()
{
vars <- ls(envir = .GlobalEnv)
rm(list = vars, envir = .GlobalEnv)
}
ftw()
a
# Error: object 'a' not found
b
# Error: object 'b' not found
@hadley
Copy link

hadley commented Feb 4, 2014

run_once <- function() {
  message("This message will self-destruct in ")
  message("5...")
  Sys.sleep(1)
  message("4...")
  Sys.sleep(1)
  message("3...")
  Sys.sleep(1)
  message("2...")
  Sys.sleep(1)
  message("1...")
  Sys.sleep(1)
  rm(list = "run_once", envir = globalenv())
}
run_once()

@rasmusab
Copy link

rasmusab commented Feb 5, 2014

Now with sound...

library(devtools)
install_github("pingr", "rasmusab")
library(pingr)

run_once <- function() {
  message("This message will self-destruct in ")
  message("5...")
  Sys.sleep(1)
  message("4...")
  Sys.sleep(1)
  message("3...")
  Sys.sleep(1)
  message("2...")
  Sys.sleep(1)
  message("1...")
  Sys.sleep(1)
  rm(list = "run_once", envir = globalenv())
  ping(9)
}
run_once()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment