Perform a task once in an R session
Perform a task once in an R session, e.g., emit a message or warning. Then give users an optional hint on how not to perform this task at all.
do_once( task, option, hint = c("You will not see this message again in this R session.", "If you never want to see this message,", sprintf("you may set options(%s = FALSE) in your .Rprofile.", option)) )
task |
Any R code expression to be evaluated once to perform a task,
e.g., |
option |
An R option name. This name should be as unique as possible in
|
hint |
A character vector to provide a hint to users on how not to
perform the task or see the message again in the current R session. Set
|
The value returned by the task
, invisibly.
do_once(message("Today's date is ", Sys.Date()), "xfun.date.reminder") # if you run it again, it will not emit the message again do_once(message("Today's date is ", Sys.Date()), "xfun.date.reminder") do_once({ Sys.sleep(2) 1 + 1 }, "xfun.task.1plus1") do_once({ Sys.sleep(2) 1 + 1 }, "xfun.task.1plus1")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.