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

Charilaos Skiadas
Sun, 09 Mar 2008 15:55:28 -0000

I ran into a weird, to me at least, problem, and hoping someone can
shed some light into it. In a nutshell, there seems to be some
problem when one calls plot with a formula, from within another
function, using ... to pass arguments, and one of those arguments
being xlim (and only xlim shows this problem). Here is an example:

 > plotw <- function(obj,...) {
+   plot(k~j, data=obj,...)
+ }
 > plotw2 <- function(obj,...) {
+   plot(obj$j,obj$k, ...)
+ }
 > df <- data.frame(j=1:3,k=1:3)
 > plotw(df, las=1, xaxs="i")
 > plotw(df, xlim=c(0,4))
Error in eval(expr, envir, enclos) :
   ..1 used in an incorrect context, no ... to look in
 > plotw2(df, las=1, xaxs="i")
 > plotw2(df, xlim=c(0,4))


I was guessing this might be related to some sort of argument
matching, but I don't see why xaxs doesn't cause a problem in that
case. So I am somewhat puzzled.

Thanks in advance.
Haris Skiadas
Department of Mathematics and Computer Science
Hanover College