[R] Puzzled by the "call" component of object returned by xyplot() from lattice.

Rolf Turner r@turner @end|ng |rom @uck|@nd@@c@nz
Sat Mar 28 07:16:11 CET 2020

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

More information about the R-help mailing list