Skip to content
Prev 275934 / 398503 Next

Generic Plot and save function

Hi,

Regarding, ..., you literally just pass ....  For example:

f <- function(d, ...) {
  lapply(d, mean, ...)
}

f(1:10) # but you could pass other arguments to lapply.

Regarding saving, my thought would be to just switch which device is started based on path.  I'm sure thre are other, possibly cleverer ways out there.

foo <- function(d, path = NULL, ...) {
  if (!is.null(path)) {
    postscript(paste(path, "plot1.eps", sep=''), other settings)
  } else dev.new()

  barplot(d, ...)

## the postscript device needs to be shutdown
## but if going to default device, probably do not want
## it closed before user can view it
  if (!is.null(path)) dev.off()
}

Hope this helps,

Josh

PS all typed on my phone so expect typos
On Oct 30, 2011, at 14:48, Alaios <alaios at yahoo.com> wrote: