skip_run_if {runonce} | R Documentation |
Skip code
Description
Skip code if all conditions are fulfilled. The code should not return anything.
Usage
skip_run_if(code, cond = NULL, files = NULL, timing = TRUE)
Arguments
code |
Code to run. Do not forget to wrap it with |
cond |
Condition to be fulfilled to skip running |
files |
Character vector of file path(s). Default is |
timing |
Whether to print timing of running code? Default is |
Value
NULL
, invisibly.
Examples
# Prepare some temporary file
tmp <- tempfile(fileext = ".txt")
# Run once because file does not exist yet
skip_run_if({
Sys.sleep(2)
write.table(iris, tmp)
}, cond = file.exists(tmp))
# Skip run because `cond` is `TRUE`
skip_run_if({
Sys.sleep(2)
write.table(iris, tmp)
}, cond = file.exists(tmp))
# Skip run because file exists
skip_run_if({
Sys.sleep(2)
write.table(iris, tmp)
}, files = tmp)
[Package runonce version 0.2.3 Index]