Re: Puzzled by the "call" component of object returned by xyplot() from lattice.
This behavior has nothing to do with S3 methods:
> f <- function(x,y,...) xyplot(y~x, col = "red",...)
> x <- 1:5; y <- runif(5)
> z <- f(x,y)
I have **not** studied the lattice code, but assuming that it is using
match.call() to get the call it returns, it looks like the sys.call
argument it (i.e. match.call()) is given is looking up higher in the
call stack than sys.parent().
Hopefully Deepayan or a suitable someone else can provide a definitive answer.
> I have written a function that calls xyplot() from the lattice package.
> In this function (which is actually a method for plot(), I assign a value
> plotObj <- xyplot(fmla,groups=.......)
> and then either either do print(plotObj) --- to display a plot as well
> as returning plotObj, to be kept for future use/reference.
> I have just noticed that if I do
> p1 <- plot(X)
> p2 <- plot(X,transform=FALSE)
> where X is of course an object of the class for which my method gets
> used, I get p1$call to be
> and p2$call to be
> xyplot(X, transform = TRUE)
> That is, it gives the arguments supplied to the calling function (my
> plot method) in the call component, and not the arguments to xyplot().
> This seems strange to me. Should I have, uh, expected this? *Why*
> should I have expected this? Can anyone explain?
> I guess it's just idle curiosity; nothing really riding on it.
> Honorary Research Fellow
> Department of Statistics
> University of Auckland
> Phone: +64-9-373-7599 ext. 88276
> [hidden email] mailing list -- To UNSUBSCRIBE and more, see
> 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.