From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>

Date: Sun, 09 Mar 2008 17:29:16 +0000 (GMT)

Date: Sun, 09 Mar 2008 17:29:16 +0000 (GMT)

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

*> xs <- "i"
**> plotw(df, xaxs=xs)
*

fails in the same way.

I reckon

*> plotw <- function(obj,...) do.call("plot", list(k~j, data=obj,...))
*

On Sun, 9 Mar 2008, Charilaos Skiadas wrote:

> 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
*

-- Brian D. Ripley, ripley_at_stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ R-help_at_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.Received on Sun 09 Mar 2008 - 17:36:18 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Sun 09 Mar 2008 - 20:30:20 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*