[R] matching last argument in function

Alistair Gee alistair.gee at gmail.com
Tue Feb 12 18:45:30 CET 2008


I often want to temporarily modify the options() options, e.g.

a <- seq(10000001, 10000001 + 10) # some wide object

with.options <- function(..., expr) {
  options0 <- options(...)
  tryCatch(expr, finally=options(options0))
}

Then I can use:

with.options(width=160, expr = print(a))

But I'd like to avoid explicitly naming the expr argument, as in:

with.options(width=160, print(a))

How can I do this with R's argument matching? (I prefer the expr as
the last argument since it could be a long code block. Also, I'd like
with.options to take multiple options.)

TIA



More information about the R-help mailing list