Skip to content
Prev 139008 / 398506 Next

Calling plot with a formula, from within a function, using ..., and xlim

You should make a habit of using of R's debugging tools, e.g. traceback() 
which gives
6: eval(expr, envir, enclos)
5: FUN(X[[1L]], ...)
4: lapply(dots, eval, data, parent.frame())
3: plot.formula(k ~ j, data = obj, ...)
2: plot(k ~ j, data = obj, ...)
1: plotw(df, xlim = c(0, 4))

so it is not related to argument matching.  If you look closer (e.g. with 
options(error=recover)) you will see what 'dots' is in the two cases.

The help page for plot.formula() explains its scope rules.  Given those, 
it is not realistic to expect to be able to call it from within a 
function with ... arguments.

The difference in your two examples of plotw is that xaxs="i" has a 
constant value and xlim=c(0,4) is an expression.  And
fails in the same way.

I reckon
is the simplest way to do what you seem to be looking for, but it is 
probably just best to avoid functions like plot.formula with non-standard 
semantics when programming.
On Sun, 9 Mar 2008, Charilaos Skiadas wrote: