It should be possible i think. You just supply all the arguments via '...' and then cut off the last one. I don't see why this wouldn't work, but maybe i'm missing something.
Gabor On Tue, Feb 12, 2008 at 12:58:25PM -0600, Erik Iverson wrote: > Alistair - > > I don't believe this is possible. The only way formal arguments (like > expr) can be matched after a '...' is with *exact* name matching. Why > do you want to avoid explicitly naming the expr argument? > > If you always want the expr argument last, you might be able to just use > ... as the sole argument to your function, and strip off the last > element inside the function as 'expr', and use all but the last element > as your list of options. This requires that expr always be given last > though. Probably best just to explicitly name the expr argument. > > Erik Iverson > > Alistair Gee wrote: > > 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 > > > > ______________________________________________ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Csardi Gabor <[EMAIL PROTECTED]> UNIL DGM ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.