From p.dalgaard@biostat.ku.dk  Wed Nov  8 19:55:20 2000
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 08 Nov 2000 20:55:20 +0100
Subject: [Rd] substitute(x$y)) corrupts 'y' component (PR#731)
In-Reply-To: Thomas Lumley's message of "Wed, 8 Nov 2000 11:33:23 -0800 (PST)"
References: <Pine.GSO.4.21.0011081128020.3414-100000@atlas.biostat.washington.edu>
Message-ID: <x2hf5itf13.fsf@blueberry.kubism.ku.dk>

Thomas Lumley <thomas@biostat.washington.edu> writes:

>      z<-quote(x$y)
>      x<-list(y=1:3)
> and you want to produce
>      list(y=1:3)$y
> 
> Suggestions?

Double substitute and eval, but there's a hitch:

> eval(substitute(substitute(z,list(x=x)),list(z=z)))
structure(list(y = c(1, 2, 3)), .Names = "y")$y

which is hardly avoidable since

> dput(x)   
structure(list(y = c(1, 2, 3)), .Names = "y")

However, 

> x<-quote(list(y=1:3))
> eval(substitute(substitute(z,list(x=x)),list(z=z)))
list(y = 1:3)$y


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] substitute(x$y)) corrupts 'y' component (PR#731)
Peter Dalgaard BSA