Dear Deepayan,

thanks for you quick response. 

The main idea is to use trellis_object$call$x as a label in a tcltk 
interface to choose one among several plots and perform a given task (e.g. 
print on screen, export as pdf etc.). I've a script that works just fine 
in R 2.4.1 for instance, but not anymore in R >= 2.5.1 and I was wondering 
if there is a possibility to reproduce the old behaviour with the new R 
version.

I can imagine few workarounds, but they lack flexibility (e.g. using 
always the same  vector of labels vec <- paste("Plot",1:n,sep='_')) or 
simplicity (e.g. providing the labels like argument to the function that 
create the tcltk interface).

Best Regards
Vincenzo

-----------------------------------------------------------------------------------
Vincenzo Luca Di Iorio
Consultant PME User support - GSK R&D Limited
-----------------------------------------------------------------------------------




"Deepayan Sarkar" <[EMAIL PROTECTED]> 
12-Nov-2008 07:04
 
To
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
cc
"R help" <[EMAIL PROTECTED]>
Subject
Re: [R] Retrieving x argument name from a trellis object in R 2.8.0






On 11/11/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> 
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.

Reply via email to