| batch {svMisc} | R Documentation |
A function can be run in batch mode if it never fails (replace errors by
warnings) and return TRUE in case of success, or FALSE
otherwise.
batch(items, fun, ..., show.progress = !isAqua() && !isJGR(),
suppress.messages = show.progress, verbose = TRUE)
items |
the items (usually, arguments vector of character strings) on
which to apply |
fun |
the function to run (must return |
... |
further arguments to pass the |
show.progress |
do we show progression as item x on y... message? This
uses the |
suppress.messages |
are messages from the batcheable function suppressed?
Only warnings will be issued. Recommended if |
verbose |
display start and end messages if |
Philippe Grosjean <phgrosjean@sciviews.org>
## Here is a fake batcheable process
fakeProc <- function (file) {
message("Processing ", file, "...")
flush.console()
Sys.sleep(0.5)
if (runif(1) > 0.7) { # Fails
warning("fakeProc was unable to process ", file)
return(invisible(FALSE))
} else return(invisible(TRUE))
}
## Run it in batch mode on five items
files <- paste("file", 1:5, sep = "")
batch(files, fakeProc)