[Sciviews-commits] r485 - in pkg/svMisc: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jul 11 00:49:42 CEST 2012
Author: phgrosjean
Date: 2012-07-11 00:49:42 +0200 (Wed, 11 Jul 2012)
New Revision: 485
Modified:
pkg/svMisc/R/batch.R
pkg/svMisc/man/batch.Rd
Log:
Added verbose argument to the batch() function in svMisc
Modified: pkg/svMisc/R/batch.R
===================================================================
--- pkg/svMisc/R/batch.R 2012-07-08 15:35:35 UTC (rev 484)
+++ pkg/svMisc/R/batch.R 2012-07-10 22:49:42 UTC (rev 485)
@@ -5,14 +5,17 @@
fun, ##<< the function to be run in batch mode
..., ##<< further arguments passed to the process function
show.progress = !isAqua() && !isJGR(), ##<< whether we display a progression message
-suppress.messages = show.progress) ##<< do we suppress simple messages?
+suppress.messages = show.progress, ##<< do we suppress simple messages?
+verbose = TRUE) ##<< display start and end messages
{
if (!is.function(fun)) stop("'fun' must be a function")
## Preparation of the batch process...
owarn <- options(warn = 1) # Issue warnings immediatelly!
on.exit(options(owarn))
- message("Running the batch process with ", deparse(substitute(fun)), "...")
+ verbose <- isTRUE(as.logical(verbose))
+ if (verbose) message("Running the batch process with ",
+ deparse(substitute(fun)), "...")
n <- length(items)
if (n < 1) {
warning("No items to process!")
@@ -21,9 +24,9 @@
ok <- rep(NA, n) # A vector with results
## Do we show progression?
- if (!isTRUE(show.progress))
+ if (!isTRUE(as.logical(show.progress)))
progress <- function (...) return() # Fake progress() function
- if (!isTRUE(suppress.messages))
+ if (!isTRUE(as.logical(suppress.messages)))
suppressMessages <- function (x) return(x) # Fake suppressMessages() function
## Run fun() for each item
@@ -35,7 +38,8 @@
flush.console()
}
progress(n + 1, n) # Cancel progression message
- message("Processed successfully ", sum(ok, na.rm = TRUE), " items on ", n, " (see .last.batch)")
+ if (verbose) message("Processed successfully ", sum(ok, na.rm = TRUE),
+ " items on ", n, " (see .last.batch)")
## Record .last.batch variable in TempEnv
lastBatch <- structure(sum(ok, na.rm = TRUE) == n, items = items, ok = ok)
assignTemp(".last.batch", lastBatch)
Modified: pkg/svMisc/man/batch.Rd
===================================================================
--- pkg/svMisc/man/batch.Rd 2012-07-08 15:35:35 UTC (rev 484)
+++ pkg/svMisc/man/batch.Rd 2012-07-10 22:49:42 UTC (rev 485)
@@ -10,7 +10,7 @@
\usage{
batch(items, fun, ..., show.progress = !isAqua() && !isJGR(),
- suppress.messages = show.progress)
+ suppress.messages = show.progress, verbose = TRUE)
}
\arguments{
@@ -23,6 +23,7 @@
uses the \code{progress()} function. }
\item{suppress.messages}{ are messages from the batcheable function suppressed?
Only warnings will be issued. Recommended if \code{show.progress = TRUE}. }
+ \item{verbose}{ display start and end messages if \code{TRUE} (default). }
}
\author{ Philippe Grosjean <phgrosjean at sciviews.org> }
More information about the Sciviews-commits
mailing list