Re: [R] Retrieving x argument name from a trellis object in R 2.8.0

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Tue, 11 Nov 2008 22:04:14 -0800

On 11/11/08, vincenzo.2.di-iorio_at_gsk.com <vincenzo.2.di-iorio_at_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_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.
>



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 Wed 12 Nov 2008 - 06:08:30 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 Wed 12 Nov 2008 - 16:30:24 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.

list of date sections of archive