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

cberry@tajo.ucsd.edu cberry@tajo.ucsd.edu
Wed, 8 Nov 2000 19:59:06 +0100 (MET)


viz.


> (function(x,y=a) substitute(x$y))(x)
x$a
> (function(x,y=a) substitute(x$y))(list(y=1:3))
list(y = 1:3)$a
> (function(x,y) eval(substitute(substitute(y))))(x=list(y=1:3),y=x$y)
list(y = 1:3)$x$y


The behavior I expect and want is like that in Splus 3.4:

> (function(x,y=a) substitute(x$y))(x)
x$y
> (function(x,y=a) substitute(x$y))(list(y=1:3))
list(y = 1:3)$y
> (function(x,y) eval(substitute(substitute(y))))(x=list(y=1:3),y=x$y)
list(y = 1:3)$y

Is there a workaround to achieve this behavior under fairly general
circumstances, i.e. when one does not know whether to expect an object
with a component, but encounters one?

Chuck Berry
--please do not edit the information below--

Version:
 platform = sparc-sun-solaris2.7
 arch = sparc
 os = solaris2.7
 system = sparc, solaris2.7
 status = 
 major = 1
 minor = 1.0
 year = 2000
 month = June
 day = 15
 language = R

Search Path:
 .GlobalEnv, package:bqtl, Autoloads, package:base
> 

-- 
Charles C. Berry                        (858) 534-2098 
                                         Dept of Family/Preventive
Medicine
E mailto:cberry@tajo.ucsd.edu	         UC San Diego
http://hacuna.ucsd.edu/members/ccb.html  La Jolla, San Diego 92093-0645

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._