Dear Deepayan, First of all I'm sorry for resuming such an old thread, but I think I may have found an easy fix.
Replacing in "xyplot.formula" (and similar internal functions for the other Trellis plots) foo$call <- sys.call(sys.parent()) foo$call[[1]] <- quote(xyplot) with foo$call <- match.call() foo$call[[1]] <- quote(xyplot) will restore the correct behaviour while keeping the new better value for the call component of a trellis object introduced in lattice version 0.16 or higher, that if I understand correctly depends on the second (unchanged) line. Best regards Vincenzo ----------------------------------------------------------------------------------- Vincenzo Luca Di Iorio Consultant PME User support - GSK R&D Limited ----------------------------------------------------------------------------------- "Deepayan Sarkar" <deepayan.sar...@gmail.com> 12-Nov-2008 07:04 To "vincenzo.2.di-io...@gsk.com" <vincenzo.2.di-io...@gsk.com> cc "R help" <r-h...@stat.math.ethz.ch> Subject Re: [R] Retrieving x argument name from a trellis object in R 2.8.0 On 11/11/08, vincenzo.2.di-io...@gsk.com <vincenzo.2.di-io...@gsk.com> wrote: > Dear all, > > let consider the following function: > > Fun1 <- function() { > library(lattice) > plot1 <- 1:10~1:10 > pl1 <- xyplot(plot1) > return(pl1$call$x) > } > > In R 2.5.0 (or older version) we have > > > Fun1() > plot1 > > but starting from R 2.5.1 until the latest R 2.8.0 we obtain instead > > > Fun1() > NULL > > because pl1$call seems to be equal to xyplot() without arguments. > > Something like xyplot(x=plot1) doesn?t work either. Again we have that > pl1$call is equal to xyplot() without arguments > > The situation is slightly different if we call the xyplot in the global > environment: > > > plot1 <- 1:10~1:10 > > pl1 <- xyplot(plot1) > > pl2 <- xyplot(x=plot1) > > then we have > > > pl1$call > xyplot(plot1) > > pl1$call$x > NULL > > but at least > > > pl2$call > xyplot(x = plot1) > > pl2$call$x > plot1 This is what I would have expected. I'm surprised at the odd behaviour when xyplot() is called inside a function, which is probably caused by my lack of understanding of how sys.call() works. However, the 'call' component is provided mainly for cosmetic reasons, and was never intended to be used programmatically. Why do you need this? -Deepayan > Someone knows if in R 2.8.0 it is possible to retrieve the name of the x > argument (i.e. plot1) directly from an object of class ?trellis? when the > corresponding lattice function (e.g. xyplot) is inside another function > (e.g. Fun1)? > > Thanks in advance > Vincenzo > > ----------------------------------------------------------------------------------- > Vincenzo Luca Di Iorio > Consultant PME User support - GSK R&D Limited > ----------------------------------------------------------------------------------- > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@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. > [[alternative HTML version deleted]] ______________________________________________ R-help@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.