Description Usage Arguments Value Examples
Skip code if all conditions are fulfilled. The code should not return anything.
1 | skip_run_if(code, cond = NULL, files = NULL, timing = TRUE)
|
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 |
NULL
, invisibly.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | # 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.