Skip to content

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

2 messages · Rolf Turner, Bert Gunter

#
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)
and

    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

    xyplot(X)

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.

Thanks.

cheers,

Rolf
#
Rolf:

This behavior has nothing to do with S3 methods:
xyplot(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.

Cheers,
Bert
On Fri, Mar 27, 2020 at 11:16 PM Rolf Turner <r.turner at auckland.ac.nz> wrote: